Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string s;
- cout << "s = " << s << endl;
- s = "This is nice!";
- cout << "s = " << s << endl;
- cout << s.at(1) << endl;
- string word;
- cout << "Enter a word to append: "; cin >> word;
- s += word;
- cout << "s = " << s << endl;
- cout << s.length() << endl;
- s.clear();
- cout << "s = " << s << endl;
- s = "ABC";
- cout << "s = " << s << endl;
- s.append("DEF");
- cout << "s = " << s << endl;
- s.insert(3,"123"); //inserts string after 3 character
- cout << "s = " << s << endl;
- s.replace(0,3,"XXX"); //replaces string starting from 0 to number of chars with sa XXX
- cout << "s = " << s << endl;
- cout << s.find("123") << endl;
- cout << s.substr(3) << endl;
- cout << s.substr(3,2) << endl;
- system("Pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement