C++ 如何在C++;?
我想从用户那里获取多行输入。但当我运行程序并在这里写下“你好,我的名字叫us umer”时,我就开始写新行了。程序运行。我想写新台词。这是我读取输入的代码C++ 如何在C++;?,c++,C++,我想从用户那里获取多行输入。但当我运行程序并在这里写下“你好,我的名字叫us umer”时,我就开始写新行了。程序运行。我想写新台词。这是我读取输入的代码 string text; cout<<"Enter the text"<<endl; getline(cin,text); 字符串文本; cout您想对多行使用循环 while(getline(cin,line)) { cout << line << endl; //
string text;
cout<<"Enter the text"<<endl;
getline(cin,text);
字符串文本;
cout您想对多行使用循环
while(getline(cin,line))
{
cout << line << endl;
//do something
}
while(getline(cin,line))
{
cout您想对多行使用循环
while(getline(cin,line))
{
cout << line << endl;
//do something
}
while(getline(cin,line))
{
但我的问题是用户将如何运行该程序?当我输入时,新行出现。我如何知道,用户将输入其所有文本?@Umer:当用户输入EOF
。在linux中是Ctrl-D。谢谢buddey。在windows中是Ctrl+z。但我的问题是用户将如何运行该程序?当我输入时,新行出现。我如何知道,用户将输入其所有文本l text?@Umer:当用户输入EOF
。在linux中是Ctrl-D。谢谢你,巴迪。在windows中是Ctrl+z。