Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/137.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 中断cin>&燃气轮机;str while循环_C++ - Fatal编程技术网

C++ 中断cin>&燃气轮机;str while循环

C++ 中断cin>&燃气轮机;str while循环,c++,C++,当我使用Ctrl+D时,它显示: 进程已完成,退出代码为0 而且,循环后面的代码永远不会执行(cout语句)。如果我想继续执行这个程序呢 string str; while(cin >> str); cout << "outside of the loop"; return 0 string-str; 而(cin>>str); cout我认为这是Clion的一个bug,因为当我尝试在终端上运行时,它就像一个符咒。或者,我更喜欢std::cerr而不是std::cout

当我使用Ctrl+D时,它显示:

进程已完成,退出代码为0
而且,循环后面的代码永远不会执行(cout语句)。如果我想继续执行这个程序呢

string str;
while(cin >> str);
cout << "outside of the loop";
return 0
string-str;
而(cin>>str);

cout我认为这是Clion的一个bug,因为当我尝试在终端上运行时,它就像一个符咒。或者,我更喜欢
std::cerr
而不是
std::cout
,它在Clion和终端上都能工作


而不是处理EOF(ctrl-d)。您确定吗?你可能就是没时间看?或者你错过它是因为它不在自己的线路上?尝试在输出后添加另一个输入(例如使用),或添加一个尾随换行符。尝试
“循环外\n”
@Some“尝试添加另一个输入…”这不需要
清除()
cin
?从命令行运行您的程序。当程序从main返回时,缓冲区将被刷新。这是我的错误。我编辑过@本贾明林德利