C++ string Looping backward via string::reverse_iterator

Description

C++ string Looping backward via string::reverse_iterator

#include <iostream> 
#include <string> 

using namespace std; 

int main(int argc, char *argv [])
{   //from  w  w w  .jav  a  2 s  .  c  o m
        string myString{ "This is my string!" }; 

        for (string::reverse_iterator iter = myString.rbegin(); iter != myString.rend(); ++iter) 
        { 
                cout << *iter << endl; 
        } 
        return 0; 
}



PreviousNext

Related