C++ String Example

 

string Str1 = “To be or not to be, that is the question”;

string Str2 = “ big“;

string Str3 = Str1.substr(6, 12);

 

Str1.insert(31, Str2);

Str1.replace(Str1.find(“to be”, 0), 5, “tuba”);

Str1.erase(9, 4);

 

cout << Str1 << endl;

 

for (int i = 0; i < Str3.length( ); i++)

          cout << Str3[i];