1. 直接输入法
string word;
while (cin>>word)
{
process(word);
}
2.字符串流法
string line,word;
while (getline(cin,line))
{
istringstream stream(line);
while (stream>>word)
{
process(word);
}
}
3.文件流法
ifstream input;
string s;
vector<string>::const_iterator it = files.begin();
while (it!=file.end())
{
input.open(it->c_str());
if (!input)
{
break;
}
while (input>>s)
{
process(s);
}
input.close();
input.clear();
++it;
}