Range-Based for with Constant Access on string value - C++ STL

C++ examples for STL:string

Description

Range-Based for with Constant Access on string value

Demo Code

#include <iostream> 
#include <string> 

using namespace std; 

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

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

Result


Related Tutorials