I'm using Visual Studio 2010 and Windows 7 x64
The command prompt closes after exit, even though I used "Start without debug". Is there a setting somewhere that I can use?
You can simply press Ctrl + F5 instead of F5 to run the built code. Then it will prompt you to press any key to continue. Or you can use this line -> system("pause"); at the end of the code to make it wait until you press any key.
Because it's finished. When console applications have completed executing and return from their main method, the associated console window automatically closes.
Before the end of your code, insert this line: system("pause"); This will keep the console until you hit a key. It also printed "Press any key to continue . . ." for me.
You can simply press Ctrl+F5 instead of F5 to run the built code. Then it will prompt you to press any key to continue. Or you can use this line -> system("pause");
at the end of the code to make it wait until you press any key.
However, if you use the above line, system("pause");
and press Ctrl+F5 to run, it will prompt you twice!
Yes, in VS2010 they changed this behavior somewhy.
Open your project and navigate to the following menu: Project -> YourProjectName Properties -> Configuration Properties -> Linker -> System. There in the field SubSystem use the drop-down to select Console (/SUBSYSTEM:CONSOLE) and apply the change.
"Start without debugging" should do the right thing now.
Or, if you write in C++ or in C, put
system("pause");
at the end of your program, then you'll get "Press any key to continue..." even when running in debug mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With