Decrementing string::iterator - C++ STL

C++ examples for STL:string

Description

Decrementing string::iterator

Demo Code

#include <iostream> 
#include <string> 

using namespace std; 

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


        for (string::iterator iter = myString.end()-1; iter != myString.begin(); --iter) 
        { 
                cout << *iter << endl; 
        } 
        return 0; 
}

Result


Related Tutorials