hi all i am a beginner and i use the devc++ to compile my programs ,here is my question ,after i compile my program the window disappears without giving me a chance to view my excutable file. i did my homework and found this piece of code online ,(supposed to be written by the same guy who wrote the dev c++ compiler ) and still can't get it done , here is the code,am sure some of you smart guys/gals will figure it out and give me an answer
If you execute your program (with or without parameters), you may notice something peculiar; a console window will pop up, flash some text and disappear. The problem is that, if directly executed, console program windows close after the program exits.
You can solve this problem one of two ways:
Method 1 - Scaffolding:
Add the following code before any return statement in main() or any exit() or abort() statement (in any function):
/* Scaffolding code for testing purposes */
cout << "Press ENTER to continue..." << endl;
/* End Scaffolding */
This will give you a chance to view any output before the program terminates and the window closes.
Method 2 - Command-prompt:
Alternatively, instead of using Dev-C++ to invoke your program, you can just open an MS-DOS Prompt, go to the directory where your program was compiled (i.e. where you saved the project) and enter the program name (along with any parameters). The command-prompt window will not close when the program terminates.
For what it's worth, I use the command-line method.