FlyingWaffle
FlyingWaffle

Reputation: 33

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?

Upvotes: 2

Views: 2373

Answers (1)

Claus J&#248;rgensen
Claus J&#248;rgensen

Reputation: 26336

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.

Upvotes: 3

Related Questions