C++ auto with string iterator inside for Loops
#include <iostream> #include <string> using namespace std; int main(int argc, char *argv []) { //from ww w. ja v a 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; }