#include #include #include #include using namespace std; int main(){ cout << endl<< "*** Exercise 3.14 -- Version with iterators****" << endl<< endl<<"Please enter some text (ENTER and Ctrl+D at the end)"<< endl; vector vecinput; // vector to store the text string input; // a string to store the input temporarily while(cin>>input) vecinput.push_back(input);//Add to vector of strings cout << endl<<"Now let's transform words into upper case and print eight in each line" << endl; vector::size_type i8=0;// i8 is a counter of words per line for(vector::iterator iter=vecinput.begin();iter!=vecinput.end(); ++iter){ string word=*iter; // Store word in a temporary string for(string::size_type j=0;j!= word.size(); ++j){ word[j]=toupper(word[j]); //convert to upper case } if(i8<8){//Print in a line... cout << word <<" "; ++i8; } else {//... until we have eight words. Then start a new line cout << endl << word; i8=0; } } cout << endl; return 0; }