views:

53

answers:

3

When I execute my program in Visual Studio (just a simple hello world app) it terminates and closes the console window immediately, rather than waiting for me to close it manually. I have gotten round this by including cin.get() at the end of the program, but my instructor has just told me that I shouldn't have to do that, and that he was able to run the same program last night without having to enter the extra line.

Is this something in the setup of Visual Studio?


Update

I've tried using Ctrl+F5, but that just makes the console disappear even faster.

+1  A: 

Start in debug mode ;)

Florian
+1  A: 

You can set a breakpoint and start the application in Debug mode. This way the IDE will halt at the breakpoint and the window doesn't get closed until you continue the execution of your code.

skelkingur
+2  A: 

This is be design and your instructor is incorrect. Try launching a .bat file from a folder view and you get precisely the same behaviour!

You can

  • Set a breakpoint

    Ask for user input via Console.readline()

    Run to cursor

Alan Simes