Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
The modern std::string class from the <string> header. It handles memory automatically and provides rich features for text manipulation.
string s1 = "Hello"; string s2 = "World"; string s3 = s1 + " " + s2; // Concatenation cout << s3.length(); // 11 cout << s3[0]; // 'H' (Access)
Grows and shrinks automatically as you add or remove characters.
Use s.at(i) for bounds-checked access; it throws an error if the index is invalid.
Prefer std::string over C-style character arrays. It's safer, more flexible, and integrates better with STL algorithms.