Possible Duplicate:
C++ char* vs std::string
Is there any advantage to using char*’s instead of std::string?
I know char*’s are usually defined on the stack, so we know exactly how much memory we’ll use, is this actually a good argument for their use? Or is std::string better in every way?
If you’re writing in C++ then std::string will be better in most cases you’ll encounter. Instead, a few cases when you might want to use char*’s:
-Compatibility with old C code (although std::string’s c_str() method handles most of this)
-To conserve memory (std::string will likely have more overhead)
-Cases where you want to make sure you know where the memory is at, such as network code or shared memory