C++ for each loop on string

Description

C++ for each loop on string

#include <iostream> 
#include <string> 

using namespace std; 

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

        for (char &letter : myString) 
        { 
                cout << letter << endl; 
        } 
        return 0; 
}



PreviousNext

Related