What's the point in using the std::string class type if it isn't supported by <string.h> header functions?
Let me turn that around.
What's the point of using <string.h> header functions when they don't work with the std::string class type?
I ask because MS Visual C++ 2008 Express Edition uses the string type, and I need to use strcat on it somehow
Just use the += operator:
1 2 3 4
string foo = "This is ";
foo += "an example";
// foo == "This is an example"
std::string provides several benefits over char arrays:
- dynamic resizing
- no buffer overflow problems
- memory management (no memory leaks)
- recorded length means faster concatenation. strcat/strlen have to parse the whole string every call, whereas string's .length() and += operator don't.