c++如何用while循环输入字符串,按回车键结束

如题所述

第1个回答  2019-10-13
#include<iostream>

using namespace std;

int main()
{
string s;
char c;

while((c=cin.get())!='\n')
s.append(1,c)
cout<<s<<endl;
return 0;
}
相似回答