Using string Iterators to Alter Data - C++ STL

C++ examples for STL:string

Description

Using string Iterators to Alter Data

Demo Code

#include <iostream> 
#include <string> 

using namespace std; 

int main(int argc, char *argv [])
{   /*from   w  ww  .ja v  a2s  . c  om*/
        string myString{ "This is my string!" }; 

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

Result


Related Tutorials