|
-
December 5th, 2003, 02:47 PM
#1
Don't close the DOS output window
Ok, I am running VC++ 6.0. How do I tell it NOT to close the output window of a Hello, world! style project. It is so fast I can't see anything.
I've been searching through all tabs on each of the three of Options, Settings, and Customize menus. There appears to be nothing like that. I know on previous versions you could tell it to wait before closing (U-close the x box), and also you could supply command line arguments (which I don't care about here.)
-
December 5th, 2003, 02:51 PM
#2
One solution is to add, at the end of main, a call to getchar()...
Code:
#ifdef _DEBUG
getchar();
#endif
Or you could call system( "pause" );:
Code:
#ifdef _DEBUG
system( "pause" );
#endif
Don't forget to #include the appropriate headers...
Thought for the day/week/month/year:
Windows System Error 4006:
Replication with a nonconfigured partner is not allowed.
-
December 5th, 2003, 02:56 PM
#3
Learn how the command prompt works.
It executes code, and then closes once the program is done. It does this when you double click, or just outright execute a DOS program but not within a command prompt.
Either open the command prompt, transverse to the directory and execute the executable within the command prompt.
or
Add this to your code
Code:
#include <cstdlib> //Include this header
Then figure out where you want your program to pause (right before the end of the int main() function) and put:
-
December 5th, 2003, 05:04 PM
#4
I understand how it works.
I know how to pause and sleep and things.
I was asking if anyone knew how to tell Visual Studio to not close it. Versions prior to 6 (4 at least) have a specific setting to both add command line arguments when running and to not close the window when execution finishes. Evidently that has been removed, or at least well-hidden, in version 6, for no sensible reason.
-
December 5th, 2003, 10:36 PM
#5
I've not seen a setting that controls it, and I've not spent time to figure out what influences it, but sometimes (when debugging a console app with MSVC++ 6.0) after an app terminates the console will prompt for a keypress when debugging, and sometimes it will not. As a result, I tend to use getchar/system to ensure that the console only "disappears" when I'm ready for it to.
Thought for the day/week/month/year:
Windows System Error 4006:
Replication with a nonconfigured partner is not allowed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|