Running a console program
-
Hi, I have do a console program with Visual C++ 5.0. When I run this program from the Visual IDE, the console program run in a DOS window. When the program is terminated , the DOS window keeps open. When I run the same console program from the Explorer or from the desktop, the DOS window automatically close when the program is finish. How can I get the DOS window still opened when my console program ends? (I can do this with a batch file, but I want to know if it is possible without a batch file) I have check the properties and I get only one or two tabs. I can't control the screen. Thanks, Claude
-
Hi, I have do a console program with Visual C++ 5.0. When I run this program from the Visual IDE, the console program run in a DOS window. When the program is terminated , the DOS window keeps open. When I run the same console program from the Explorer or from the desktop, the DOS window automatically close when the program is finish. How can I get the DOS window still opened when my console program ends? (I can do this with a batch file, but I want to know if it is possible without a batch file) I have check the properties and I get only one or two tabs. I can't control the screen. Thanks, Claude
Hello, This is the trick. VC++ does not directly run your application. Instead it hands it over to another console application vcspawn.exe in the VC++ bin directory. This executes your program as a process and wait till it completes and then prints "Press any key to continue". It then immediately sets itself to receive an input from the user and any key pressed is enough to get it to the end of its main(). To simply emulate this, at the end of your main(), do something similar to int main() { .....// your main code ends here // End of main processing cout<<"Press any key to continue..."<