How to stop console from closing on exit?

segfault picture segfault · Nov 7, 2010 · Viewed 123k times · Source

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?

Answer

Suhas Bharadwaj picture Suhas Bharadwaj · Jan 22, 2013

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!