The advantages of a string object over a C-style char* are obvious. Yet there are times you may still need a null-terminated char*, for example, when legacy C code is still being used in your programs. The standard string class has the c_str() member function which returns the const char* representation of its object:
void f() {string s;s = "Hello";if( strcmp( s.c_str(), "Hello")== 0) //are they identical?cout <<"identical"<
Please note: