Move backward through a string from end to beginning via string::reverse_iterator - C++ STL

C++ examples for STL:string

Description

Move backward through a string from end to beginning via string::reverse_iterator

Demo Code

#include <iostream> 
#include <string> 

using namespace std; 

int main(int argc, char *argv [])
{   // ww w  . ja va  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; 
}

Result


Related Tutorials