std::string str = "Hello World!"; str.pop_back(); std::cout << str; // Output: Hello World
std::string str = "12345"; while (!str.empty()) { std::cout << str << std::endl; str.pop_back(); }
12345 1234 123 12 1Overall, the std::string::pop_back function is a useful tool when working with strings in C++.