1
String Functions
C++
string s = "Hello World";
s.length(); // 11
s.substr(0, 5); // "Hello"
s.find("World"); // 6 (string::npos if not found)
s += "!"; // append
s.replace(0, 5, "Hi"); // "Hi World!"
toupper(s[0]); // single char to upper case
stoi("123"); // string → int
to_string(456); // int → string
getline(cin, s); // read a full line with spaces