Visual C++ EXE Question

This is a discussion on Visual C++ EXE Question within the Windows Programming forums, part of the Platform Specific Boards category; When creating a simple C++ Source file in Visual C++ 6.0, compiling it and executing the .exe file it creates ...

  1. #1
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187

    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...

  2. #2
    31173 h4x0r gnu-ehacks's Avatar
    Join Date
    Nov 2001
    Posts
    556
    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.
    What will people say if they hear that I'm a Jesus freak?
    What will people do if they find that it's true?
    I don't really care if they label me a Jesus freak, there is no disguising the truth!

    Jesus Freak, D.C. Talk

    -gnu-ehacks

  3. #3
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    OK, That's cool

    I was just wondering if you could prevent the
    small program window from Auto-Closing.

    ==

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    202
    Without going through DOS you can get the same effect by adding:

    #include <conio.h>
    //your code
    getch ();
    } //end of source code

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    164
    I think the 'pause' command is better:

    #include <cstdlib>

    system("pause");
    // Gliptic

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    5
    So, with system("pause"), does user input undo that, or how else would you unpause it?

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    >>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.

  8. #8
    Registered User
    Join Date
    Sep 2001
    Posts
    164
    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.

  9. #9
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  2. What's wrong with this code??
    By Xanth in forum C Programming
    Replies: 11
    Last Post: 12-23-2004, 01:41 PM
  3. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  4. visual c++ question (paramters)
    By rxg00u in forum Windows Programming
    Replies: 0
    Last Post: 04-11-2002, 07:50 AM
  5. Visual Studio C Question
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 11-29-2001, 01:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21