Stop my Windows Console from disappearing everytime I run my program?


Match word(s).

If you have any questions or comments,
please visit us on the Forums.

FAQ > How do I... (Level 1) > Stop my Windows Console from disappearing everytime I run my program?

This item was added on: 2003/01/28

Within some IDEs, you can press a hot-key combination or click a button, and your compiler will spring forth and compile your code. Then you can click on the "Run" option to execute your program, and up pops an output window that shows you the pretty output. But to your dismay the window disappears in a flash, long before you've had chance to see the results of your hard work. Sound familiar?

Well, the answer is quite simple. Your program is actually running and completing. There is nothing left to hold the window open, so it closes. There are a few ways around this problem; try one of these and see what works best for you:


  • Run your program from the command line rather than the IDE (not exactly what most people want).
  • Do a blocking read for user input. Some options are given in the FAQ: "How do I get my program to wait for a keypress?"
  • Send your program's output to an alternative source for testing, such as a file.

Script provided by SmartCGIs