A lot of users have been asking why their console application terminates immediately after running/debugging their program in the Visual C++ IDE.  Users claim to see a quick flash of the console application and then it disappears.
This is due to the fact that when your program is run, it creates a temporary console session to invoke your application.  Without any code to explicitly keep the console open (i.e. requiring that the user enter in a value using cin >>), the console terminates immediately after the code completes.  This is why you see a quick flash of your console application.
There are a few things you can do to see the output of your program.
  1. Start your application without debugging (Ctrl+F5).  When doing this, the C++ IDE creates a batch file that executes your code and displays the text “Press any key to continue”.  This will allow the console to stay on the screen and allow you to view the output.
  2. Set a breakpoint in the code and run with debugging (F5).  When you hit the breakpoint, you can see the console window’s current output.
  3. Run the application from a command prompt.  Press Start->All Programs->Visual C++ 2005 Express Edition->Visual Studio Tools->Visual Studio 2005 command prompt.  Then navigate to the directory (using ‘cd’) where the .exe is located.  Run the application by typing in the name of the .exe at the command prompt.  You will see the output from the program in the command prompt.

Hopefully this will help people get their first C++ application up and running!

Original Post @ http://social.msdn.microsoft.com/Forums/en/Vsexpressvc/thread/1555ce45-8313-4669-a31e-b95b5d28c787


no comment untill now

Sorry, comments closed.