Mega Code Archive

 
Categories / C++ / String
 

Use a reverse iterator to display the string in reverse

#include <iostream> #include <string> #include <cctype> #include <algorithm> #include <vector> using namespace std; int main() {   string strA("This is a test.");   string::reverse_iterator ritr;   for(ritr = strA.rbegin(); ritr != strA.rend(); ++ritr)     cout << *ritr;   return 0; }