C++ examples for STL:string
To reverse a string "in place" without using a temporary string, use the reverse function template in the <algorithm> header:
#include <string> #include <iostream> using namespace std; int main() {// w w w . ja v a 2s .co m string s = "this is a test"; cout << s << endl; std::reverse(s.begin(), s.end()); cout << s; }