// @topic T53315 12/11/2012 -- STL containers and iterators // @brief std::vector, std::string, vector iterator, toupper(), tolower(), auto #include <string> #include <iostream> #include <vector> int main() { std::string str = "Hello World!"; //std::string str( 15, 'z' ); std::vector< int > vect( str.length() ); int idx = 0; for ( ; idx < str.length(); ++idx ) { vect[ idx ] = toupper( str[ idx ] ); //std::cout << vect[ idx ] << ' '; } std::vector< int >::iterator it_start = vect.begin() + 1; std::vector< int >::iterator it_end = vect.end() - 2; //auto it_start = vect.begin() + 1; //auto it_end = vect.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 << char( *it_start ) << ' '; ++it_start; } std::cout << '\n'; }