C++ string const_iterator
#include <iostream> #include <string> using namespace std; int main(int argc, char *argv []) { //from w ww. j a v a2 s . c om string myString{ "This is my string!" }; for (string::const_iterator iter = myString.cbegin(); iter != myString.cend(); ++iter) { cout << *iter << endl; } for (string::const_reverse_iterator iter = myString.crbegin(); iter != myString.crend(); ++iter) { cout << *iter << endl; } return 0; }