Copy the string to another string, but backward, use reverse iterators - C++ STL

C++ examples for STL:string

Description

Copy the string to another string, but backward, use reverse iterators

Demo Code

#include <string>
#include <iostream>

using namespace std;

int main() {/*from   w  w  w.  j a  va  2  s .co m*/

     std::string s = "this is a test";
     std::string rs;

     rs.assign(s.rbegin(), s.rend());

     cout << rs;
}

Result


Related Tutorials