C++ examples for STL:string
Using auto with Standard for Loops on string value
#include <iostream> #include <string> using namespace std; int main(int argc, char *argv []) { //from ww w . ja va 2 s .co m string myString{ "This is my string!" }; for (auto iter = myString.begin(); iter != myString.end(); ++iter) { cout << *iter << endl; } for (auto iter = myString.cbegin(); iter != myString.cend(); ++iter) { cout << *iter << endl; } return 0; }