#include #include #include #include using namespace std ; int main() { //The below syntax automatically assigns the null character //at the end. string name1( "Jerry Quarry" ) ; //With the below style we need to manuall assign the //null character at the end char name2Array[] = { 'C' , 'a' , 'r' , 'l' , '\0' } ; string name2( name2Array ) ; //Safe since we have enough space in the array name3 string name3( "Thompson" ) ; printf( "%s\n" , name1.c_str() ) ; printf( "%s\n" , name2.c_str() ) ; printf( "%s\n" , name3.c_str() ) ; cout << name1 << " " << name1.length() << endl ; cout << name2 << " " << name2.length() << endl ; cout << name3 << " " << name3.length() << endl ; string name4; name4 = "Ike " ; name4.append("Ibeaubuchi"); cout << name4 << " Length of name4 is: " << name4.length() << endl ; string name5 = "Archie Moore continued boxing in his 40s."; char delimiter = ' '; // Space is the delimiter stringstream ss( name5 ); string token; while ( getline(ss, token, delimiter)) { cout << "token:" << token << endl ; } return 0 ; }