相关知识点:
size_type
vector 和许多标准库类一样都定义了一些配套类型(companion type),通过这些配套类型,能使标准库的使用与机器无关(machine-independent).
处理处于容器中的字符串的字符类型于对二维数组中元素的操作。
//modified by quanspace 2013-02-06 18:16
/* Read some text into a vector, storing each word in the input as an
*element in the vector. transform each word into uppercase letters.
*print eight words to a line.
*/
# include <iostream>
# include <vector>
# include <string>
using namespace std;
int main(){
vector<string> word_vec;
string word;
cout<<"Input some text :"<<endl;
while(cin>>word){
if(word == "esc!!!") break;
word_vec.push_back(word);
}
for(vector<string>::size_type i = 0; i != word_vec.size(); ++i){
for(int j = 0; j != word_vec[i].size(); ++j)
word_vec[i][j] = toupper(word_vec[i][j]);
if(i%8 == 0)
cout<<endl;
cout<<word_vec[i]<<" ";
}
return 0;
}

参考 C++ primer 4 edition exercises 3.14