#include#include int main() { std::string str = "hello world"; for(auto it = str.begin(); it != str.end(); ++it) { std::cout << *it; } // Output: hello world return 0; }
#includeThis function is part of the C++ Standard Library.#include int main() { std::string str = "hello world"; auto start = str.begin(); auto end = str.end() - 1; while(start < end) { std::swap(*start, *end); ++start; --end; } std::cout << str; // Output: dlrow olleh return 0; }