Monday, July 10, 2017

C++11: range-for: string

A string can be used with a range. Here is an example:
#include
#include
using namespace std;
int main()
 {
    string myString = "abc";
    for (auto i : myString)  cout << i << " ";
    return 0;
}
// Output: a b c

No comments:

Post a Comment