本文介绍了C ++:ctrl + d终止程序(ubuntu)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(C ++的新手)

我有这个简单的代码(为问题简化了):

I have this simple code (simplified for the question):

 int main()
{
    string currInput;
    while (getline(cin, currInput))
    {
    }
    cout << "wont be printed" << std::flush;
    return 0;
}

我已经调试了一段时间,我可能会错过一些东西:

I have been debugging for a while and I probably miss something:

运行它并按 + (在某些字符串之后或立即)时,它不会打印while循环之后的字符串.它只是停止运行.我认为这可能与冲洗有关,所以我也添加了这一点.我想念什么?

When running it and pressing + (after some strings or right away), it does not print the string that is after the while loop. It just stop running. I thought it might be something with flushing so I added that too.What am I missing?

PS:在调试中运行时,它会提及有关叹气信号的信息.

PS: When running in debug, it mentions something about sighup signal.

推荐答案

因此,在@manni和@rici的大量帮助下,我们找到了问题所在.

So, with a lot of help from @manni and @rici, we found the problem.

事实证明这是cLion中的一个已知问题.

It turns out to be a known problem in cLion.

请参见将EOF发送到Clion IDE中的stdin

https://intellij-support.jetbrains.com/hc/en-us/community/posts/206849765-How-to-enter-EOF-Ctrl-z-in-Run-console-

https://youtrack.jetbrains.com/issue/IDEA-12514

这篇关于C ++:ctrl + d终止程序(ubuntu)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 00:11
查看更多