std::string
std::string grows automatically. Use size, +, substr, find, replace and compare.
Example
#include <iostream>
#include <string>
int main() {
std::string s = "Hello";
s += " World";
std::cout << s.size() << " " << s.substr(0, 5) << " " << s.find("World") << "\n";
s.replace(0, 5, "Hi");
std::cout << s << "\n";
return 0;
}Result
11 Hello 6 Hi World
Exercise
Length.
s.()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.