1、string读取某一行,然后按空格分隔吹每一个string
int main() { string line,b; getline(cin,line); stringstream ss(line); while(ss>>b) { cout<<b<<endl; } }
2、getline分界符重载,以及无限读取
int main() { string s; while(getline(cin,s,'#')) //默认换行为enter,这里重载成# cout<<s<<"$"; }
int main() { string line,b; getline(cin,line); stringstream ss(line); while(ss>>b) { cout<<b<<endl; } }
int main() { string s; while(getline(cin,s,'#')) //默认换行为enter,这里重载成# cout<<s<<"$"; }