【发布时间】:2017-07-24 14:39:52
【问题描述】:
当我使用Ctrl+D时,它显示:
process finished with exit code 0
而且,循环后面的代码永远不会被执行(cout 语句)。如果我想继续执行这个程序怎么办?
string str;
while(cin >> str);
cout << "outside of the loop";
return 0
环境:适用于 Linux 的 CLion。
【问题讨论】:
-
比处理 EOF (ctrl-d)。
-
你确定吗?你可能只是没有时间看它?或者您可能会因为它不在自己的路线上而错过它?尝试在输出后添加另一个输入(使用例如
std::getline),或添加尾随换行符。 -
试试
"outside of the loop\n"。 -
@Some "尝试添加另一个输入..." 这不需要
clear()cin吗? -
从命令行运行你的程序。
标签: c++