#include#include int main() { std::string str = "hello"; for (auto it = str.begin(); it != str.end(); ++it) { std::cout << *it << '\n'; } return 0; }
#includeIn this example, we use the erase() function and end() to remove the last character of the string. Package library: Standard Library (std)#include int main() { std::string str = "hello"; str.erase(str.end() - 1); std::cout << str << '\n'; return 0; }