Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Visual Studio from Closing Program After Finish

This is probably an easy Visual Studio question, but I couldn't find it on the site.

When I "Start Debugging" a console program, it immediately exits when its finished. Is there any way to have it pause when it ends without putting an explicit pause command at the end of your program?

like image 201
Unknown Avatar asked May 12 '09 07:05

Unknown


People also ask

How do I make the output window stay in Visual Studio?

Start the project with Ctrl + F5 instead of just F5 . The console window will now stay open with the Press any key to continue . . . message after the program exits.

How do you stop a program from closing in C++?

Before the end of your code, insert this line: system("pause"); This will keep the console until you hit a key.

How do I stop the console app from closing?

The simplest method to avoid this is to start the application from Visual Studio without using debugging. You do so by selecting "Start Without Debugging" from the Debug menu or by pressing Ctrl-F5. When the program stops executing, you must press a key before the console window closes.


3 Answers

Add a breakpoint just before the application finishes.

like image 106
corné Avatar answered Sep 17 '22 20:09

corné


You can place Console.ReadLine at the end of the program. That will force program to wait for a newline character input. Or you can place breakpoint at the end of the probram.

like image 32
Vadym Stetsiak Avatar answered Sep 18 '22 20:09

Vadym Stetsiak


"Run without Debugging" does that, but I guess you want to debug still :)

like image 26
leppie Avatar answered Sep 20 '22 20:09

leppie