Automatic closing of command window

I'm a bit of a noob when it comes to VC++ been trying to pick it up over the past few days through some interesting tutorials. Anyways....my problem should (hopefully) be a very simple one. Im trying out a couple of simple programs of the HelloWorld flavour (you know, the basics) and I'm compiling them through VIsual Studio 2005. The problem is that post compilation the command window just auto closes (thats command as in command.exe or cmd.exe however the program actually being run is the exe for my code, obviously) I was wondering if it was possible to make the window stay open long enough for me to actually read the output with the Press Any Key to Continue dialogue before it closes.

Thanx.

Brokenlynx

PS: Ive already tried unchecking "close on exit" in %WINDIR%/_default.pif only seems to affect use of the 'exit' command on the command line. Any other ideas



Answer this question

Automatic closing of command window

  • Mike Walker

    Thanx for that I think the breakpoint method is probably the best way to go about it....mods can close this now. Thx for the help!

    Brokenlynx


  • rr_dot_net

    Try hitting Ctrl + F5 :)

    Is this waht you were looking for


  • Shahid Mahmood

    Hi: you can add a system call to pause at the end of your program: this should have the desired effect:

    #include <stdio.h>
    #include <stdlib.h>

    int main()
    {
    printf(
    "Hello World\n");
    system(
    "pause");
    }



  • dreadjr

    nice, appears to work. But is there a more universal way of doing this so I would'nt have to add that line to many files for example
  • OoLee

    This method, or reading a character from the input stream, seem to be usual approaches suggested on this forum. Personally I just set a breakpoint on the closing brace of main.

  • Automatic closing of command window