Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
181 views
in Technique[技术] by (71.8m points)

c++ - Can't get rid of exit code in console window

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?

question from:https://stackoverflow.com/questions/65942675/badc-solution

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...