How to stop C++ console application from exiting immediately?

Adam P picture Adam P · Mar 27, 2010 · Viewed 491.8k times · Source

Lately, I've been trying to learn C++ from this website. Unfortunately whenever I try to run one of the code samples, I see that program open for about a half second and then immediately close. Is there a way to stop the program from closing immediately so that I can see the fruits of my effort?

Answer

nabulke picture nabulke · Mar 27, 2010

If you are using Visual Studio and you are starting the console application out of the IDE:

pressing CTRL-F5 (start without debugging) will start the application and keep the console window open until you press any key.