-
Visual C++ EXE Question
When creating a simple C++ Source file in Visual C++ 6.0, compiling it and executing the .exe file it creates from windows explorer the program window it executes in automatically closes after the program has completed, not allowing me to see the final output.
How can i remedy this problem ?
Thanks...
-
Hmm...You mean the command prompt window in a console program? Well, you can just open the program from the console, instead of clicking on the icon in Windows Explorer. This takes a little DOS command knowledge, but basically all you have to know is what "CD" and "DIR" do.
-
OK, That's cool
I was just wondering if you could prevent the
small program window from Auto-Closing.
==
-
Without going through DOS you can get the same effect by adding:
#include <conio.h>
//your code
getch ();
} //end of source code
-
I think the 'pause' command is better:
#include <cstdlib>
system("pause");
-
So, with system("pause"), does user input undo that, or how else would you unpause it?
-
>>So, with system("pause"), does user input undo that
pause is an old dos command to enter inside a bat file. It would suspend excecution until the user pressed a key.
if you open a command prompt and enter "pause", you will get something like "......press any key to resume". Press a key and you will get the command prompt.
It just freezes excecution until the user presses something.
Personally, I never use anything to keep the app onscreen....if I write a console app...I use it on the command prompt.
-
I almost never writes console apps, but when I do, I run them from the VC++ IDE and it automatically keeps the window open until a key is pressed.
-