Jump to content
  • Advertisement
Sign in to follow this  
paulecoyote

Quickie - VS 2003 C++ compiler option to keep console open?

This topic is 4861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a VS 2003 C++ compiler option that keeps a console application open after it has finished running? Yeah I know I could just use cin or something at the end, but I just want that console window to stay open until I close it so I can see what it's output. I'm sure I've used the feature before, but probably in a different compiler & IDE. Cheers, Paul

Share this post


Link to post
Share on other sites
Advertisement
If you select "start without debugging" (ctrl+f5) the console will stay open, if you select "start" (F5) the console will close.

Share this post


Link to post
Share on other sites
If you run it from the command line, or a batch file, the console should also remain when the program has terminated.

Share this post


Link to post
Share on other sites
If I want it to stay open with F5 I usually just stick a breakpoint on the closing brace of main() but if there's a better way I'd love to know it. I thought I'd come across the option once before (perhaps with VC6?) but I've hunted for it in VS .NET 2003 to no avail.

Share this post


Link to post
Share on other sites

int main() {
system("PAUSE");
}


It requires no special headers or whatnot, just tack it onto the end and you get the "Press any key to continue..." thing just like if you select "Start without debugging"

CM

Share this post


Link to post
Share on other sites
Quote:
Original post by Nemesis2k2
Actually, that requires the windows.h header to be included.


Quote:
My SYSTEM(3) manpage
SYSTEM(3) Linux Programmer's Manual SYSTEM(3)

NAME
system - execute a shell command

SYNOPSIS
#include <stdlib.h>

int system (const char * string);

[...]

CONFORMING TO
ANSI C, POSIX.2, BSD 4.3


My emphisises (?). This means #include <cstdlib> for C++, and find system in the std:: namespace.

Share this post


Link to post
Share on other sites
Quote:
Original post by MaulingMonkey
My emphisises (?). This means #include <cstdlib> for C++, and find system in the std:: namespace.


I don't think any of the functions from C is wrapped in namespaces, so the std:: part isn't needed.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!