- #include <iostream>
- using namespace std;
- #include <string>
- int main() {
- string sentence="Lawrence will go";
- string place=" to the store.";
- cout << "The sentence is " << sentence.length() << " characters long." << endl;
- cout << sentence << endl;
- cout << "Append: " << place << " " << " to: " << sentence << endl;
- sentence.append(place);
- cout << "The sentence is " << sentence.length() << " characters long." << endl;
- cout << sentence << endl;
- int pos=sentence.find("go");
- sentence.insert(pos,"not ");
- cout << "The sentence is " << sentence.length() << " characters long." << endl;
- cout << sentence << endl;
- }
Raw Paste