Preventing console window from closing on Visual Studio C/C++ Console application

Martin picture Martin · Nov 21, 2009 · Viewed 470.4k times · Source

This is a probably an embarasing question as no doubt the answer is blindingly obvious.

I've used Visual Studio for years, but this is the first time I've done any 'Console Application' development.

When I run my application the console window pops up, the program output appears and then the window closes as the application exits.

Is there a way to either keep it open until I have checked the output, or view the results after the window has closed?

Answer

Tom picture Tom · Nov 21, 2009

If you run without debugging (Ctrl+F5) then by default it prompts your to press return to close the window. If you want to use the debugger, you should put a breakpoint on the last line.