Mega Code Archive

 
Categories / C++ / Data Type
 

String Size

#include <iostream> #include <string> using namespace std; int main() {     string str = "0123456789";     cout << "The current capacity of the string is:" << str.size() << endl;     str.resize( 20 );     cout << "The new capacity of the string is:"          << str.size() << endl;                cout << "The actual length of the string is: "          << strlen( str.c_str() ) << endl;     cout << "The string object after resizing "          << "to 20 a 10 character string: "          << str << endl;     str += "hello";     cout << str << endl;     return 0; }