#include<iostream>
#include<sstream>
using namespace std;
int main()
{
string str, line;
while(getline(cin, line))
{
istringstream stream(line);
while(stream>>str)
cout<<str.c_str()<<endl;
}
return 0;
}
测试:
input:
abc df e efgeg ffg
ouput:
abc
df
e
efgeg
ffg
原文链接:http://www.cppblog.com/shyli/archive/2006/10/17/13758.html