// @topic T53325 12/11/2012 -- STL containers and iterators // @brief std::string, string iterator, toupper(), tolower(), auto #include <string> #include <iostream> int main() { std::string str = "Hello World!"; int idx = 0; for ( ; idx < str.length(); ++idx ) { str[ idx ] = toupper( str[ idx ] ); std::cout << str[ idx ] << ' '; } auto x = 12345; //std::string::iterator it_start = str.begin() + 1; //std::string::iterator it_end = str.end() - 2; auto it_start = str.begin() + 1; auto it_end = str.end() - 2; int dist = it_end - it_start; std::cout << "the distance is " << dist; std::cout << '\n'; while( it_start < it_end) { *it_start = tolower( *it_start ); std::cout << *it_start << ' '; ++it_start; } std::cout << '\n'; }