I build the code, then when I try to run it, it executes and exits quickly . I am pretty sure that there is a way in the project configuration , but I forgot how .
-
duplicate http://stackoverflow.com/questions/193469/how-to-make-visual-studio-pause-after-executing-a-console-app-in-debug-mode – MK. Jan 03 '11 at 19:44
4 Answers
You can always just use getc()
before the return. Enter a character and it will exit..
Or run the VS ctrl+f5
combination, or add a breakpoint if debugging.

- 15,389
- 20
- 57
- 65
-
I tried, error C2198: 'getc' : too few arguments for call .... What to put between brackets? – BinaryLife Jan 03 '11 at 19:44
-
A way is to stick
system("PAUSE")
before the exit.
I must say the only time I used system("PAUSE") was at school when we were doing algorithm exercises. And I'm sre its bad pratice ^^
A cleaner way is to read the input like
scanf or cin
this way your program waits for a input in the keyboard

- 19,194
- 27
- 79
- 112
-
2
-
Breakpoints don't work when you use Ctrl+F5, (aka "start without debugging"). It's not a best practice, whatever that means. – Hans Passant Jan 03 '11 at 20:06
After a bit of googling, I found this solution that does not involve modifying your code. It contains a workaround that involves modifying your .vcxproj file.
To do this from within Microsoft Visual C++ 2010 Express (I'm assuming it is similar for Visual Studio 2010), open your project and navigate to the following menu: Project->$YOURPROJECTNAME Properties... ->Configuration Properties ->Linker ->System->SubSystem
Then use the dropdown to select Console (/SUBSYSTEM:CONSOLE) and apply the change.
"Start without debugging" should do the right thing now. Thanks All for your answers , but this works perfectly .

- 173
- 4
- 6
- 13