int main() { string str = "foobarbaz"; reverse(str.begin(), str.end()); cout << str; // prints "zabraboof" return 0; }