#include#include int main() { std::string str = "hello world"; auto it = str.begin(); std::cout << *it << std::endl; // Output: h return 0; }
#includeIn this example, we again create a string "ABCDEF", but this time we use the std::reverse() algorithm from the algorithm library to reverse the order of the characters in the string. We pass in the begin() and end() iterators of the string to the algorithm. The result is the string "FEDCBA" which we print to the console. Package library: C++ standard library (included in all C++ compilers)#include #include int main() { std::string str = "ABCDEF"; std::reverse(str.begin(), str.end()); std::cout << str << std::endl; // Output: FEDCBA return 0; }