C++ string iterator update string

Description

C++ string iterator update string

#include <iostream> 
#include <string> 

using namespace std; 

int main(int argc, char *argv [])
{   /*from  w ww.java2  s . co m*/
        string myString{ "This is my string!" }; 

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



PreviousNext

Related