>> C++ strings are to C strings as C++ vectors are to C arrays - pretty much better in every
way.
Yes indeed. All functions are associated with the strings . thing (sorry for my poorly chosen vocab), so you don't have to remember (taking examples from C), strcat, strlen etc. The + and = operators are overloaded, and there is a .size(), .find(), .c_str(), and lots of other functions with them, which IMO, makes them great.
fast example C++ ::
Code:
std::string MyStringA = "this is a std::string. ";
std::string MyStringB = "See how it Roars";
std::string MyStringAB = MyStringA + MyStringB;
std::cout<< '\n' << MyScringAB;// should be - this is a std::string. See how it Roars
std::cout<< '\n' << MyScringAB.size(); // the size of the string, I'm not counting it :)
obviously, if you REALLY wanted to, you could put a using namespace std;, or using std::cout; using std::string; or whatever to get rid of all those st::'s, but it's generally advised to use std::'s for large projects.
Fast example, C: (If I can remember syntaxi etc)
Code:
char *MyStringA = "this is a std::string. ";
char *MyStringB = "See how it Roars";
char MyStringAB[100];
strcpy( strcat( MyStringA, MyStringB ), MyStringAB );
// can't remember whether the destination comes first or
// last with strcpy, nor can I remember whether they shuld be
// char []'s, or char *'s or whether it makes a difference.
printf( "%s", MyStringAB );
printf( "%d", strlen( MyStringAB );
IMO, C++ way = nicer