Can't get rid of exit code in console window

梦想与她 提交于 2021-02-16 20:06:36

问题


So I run some code similar to this:

#include <iostream>
using namespace std;    //yes, I know this is bad practice

int main()
{
    int variable(0);        

    cout << "GET INPUT: ";
    cin >> variable;

    //do some math

    cout << variable << "OUTPUT";
    return 0;
}

And on the computers at school I get this output:

GET INPUT: 7
7 OUTPUT
Press any key to close this window . . .

But on my computer at home I get:

GET INPUT: 7
7 OUTPUT

e:\...\Project.exe (process 10080) exited with code 0.
Press any key to close this window . . .

The only change I've made to any settings (at home or at school) is switching my Linker SubSystem to Console.

How do I get rid of the "exit with code 0" message?


回答1:


This is actually a feature, and I wouldn't turn it off if I were you, as the console window will close immediately, without you having a chance to evaluate the output of your program.

But if you really want to, go to the top level menu, Tools > Options > Debugging > General and you can then toggle on/off "Automatically close the debug console when debugging stops"

And if you're doing continuous development, VS will "flush" the console for you when you restart debugging (F5), so you won't have to worry about closing multiple console windows.



来源:https://stackoverflow.com/questions/52121898/cant-get-rid-of-exit-code-in-console-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!