-1

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 .

BinaryLife
  • 173
  • 4
  • 6
  • 13
  • 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 Answers4

1

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.

Milan
  • 15,389
  • 20
  • 57
  • 65
0

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

Jason Rogers
  • 19,194
  • 27
  • 79
  • 112
0

Or you set a breakpoint on the last statement.

RedX
  • 14,749
  • 1
  • 53
  • 76
0

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 .

BinaryLife
  • 173
  • 4
  • 6
  • 13