Basic String Operations

std::string offers many useful functions for manipulation.

string s = "Hello";
s += " World";              // Concatenation
cout << s.length();          // Get length
cout << s.substr(0, 5);      // Substring
cout << s.find("World");    // Find position
s.replace(0, 5, "Hi");      // Replace part

These operations make std::string powerful for text processing.

← PrevNext →