方法一: string str; getline( cin,str); cout<<str; 方法二: string str; char c; while((c= cin.get())!= '\n') { str=str+c; }