👍 g++ stl_string.cpp && ./a.out
abcdefghijklmnop
16
f
f
abcdefghijklmnopqrs
true
6
efghij
abcdklmnop
axxxbcdklmnop
axxxbcdklmnopxy
axxxbcdklmnopxyz
👍 cat stl_string.cpp
#include <iostream>
using namespace std;
int main() {
string S = "abcdefghijklmnop";
cout << S << endl;
cout << S.size() << endl;
cout << S.at(5) << endl;
cout << S[5] << endl;
cout << S + "qrs" << endl;
cout << boolalpha
<< (S == "abcdefghijklmnop")
<< noboolalpha
<< endl;
cout << S.find("ghi") << endl;
cout << S.substr(4, 6) << endl;
cout << S.erase(4, 6) << endl;
cout << S.insert(1,"xxx") << endl;
cout << (S += "xy") << endl;
cout << S.append("z") << endl;
}
12.1.1 The STL String Class p556 of
17.5.1 Formatted Input and Output p887 of