C++ examples for STL:string
Using iterators that demonstrates the use of functions rbegin and rend.
#include <iostream> #include <string> int main(int argc, const char* argv[]) { std::string str = "now step live..."; std::string::reverse_iterator rit = str.rbegin(); while (rit != str.rend()) { std::cout << *(rit++);/*from ww w . j a va2s. c o m*/ } std::cout << std::endl; return 0; }