Microsoft Visual C++ DOS program quitting

This is a discussion on Microsoft Visual C++ DOS program quitting within the C++ Programming forums, part of the General Programming Boards category; I have a block of code that looks like: Code: int main() { // some code return 0; } Upon ...

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    222

    Microsoft Visual C++ DOS program quitting

    I have a block of code that looks like:

    Code:
    int main()
    {
              // some code
              return 0;
    }
    Upon program termination, I receive a prompt saying "Press any key to continue". Does anyone know what I have to do in my code so that I can skip around that step? Thanks.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    This may be the first time ever we've had it this way around.

    As far as I know, you're stuck with it. Does it also happen if you run the program from the command prompt?

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    96
    Quote Originally Posted by stanlvw View Post
    I have a block of code that looks like:

    Code:
    int main()
    {
              // some code
              return 0;
    }
    Upon program termination, I receive a prompt saying "Press any key to continue". Does anyone know what I have to do in my code so that I can skip around that step? Thanks.
    Would you happen to have a system("PAUSE") in there?

    Also, are you running the program from inside an IDE?
    Sometimes IDE's pause your console apps so the window doesn't disappear......

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    222
    Quote Originally Posted by sethjackson View Post
    Would you happen to have a system("PAUSE") in there?

    Also, are you running the program from inside an IDE?
    Sometimes IDE's pause your console apps so the window doesn't disappear......
    I don't have a system("pause") in my program. I'm reading from inside an IDE.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    VC++ adds this when you "Execute" your program because most people want it... it leaves the console (not DOS) window up so you can see any output from your program. Otherwise, when your program finishes, the console window will close.

    If you run your program by double-clicking on the exe, the console will close without the "Press any key to continue" part. If you open your own console window and run your program from the command prompt, the window will not close, and you will not get the "Press any key to continue" part either.

    Finally, if you "Run" the program from inside VC++, you will not get the "Press any key to continue" at the end. The Run command runs the program through the debugger, which is often a good idea anyway. The Execute command just runs the program in a way that is similar to what would happen if you manually ran it yourself.

  6. #6
    Registered User Stonehambey's Avatar
    Join Date
    Jan 2008
    Location
    Kent, UK
    Posts
    118
    Here is a video tutorial which might help explain it better, it helped me

    http://msdn2.microsoft.com/en-us/visualc/cc296427.aspx

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. Problem Compiling Program
    By wco5002 in forum C++ Programming
    Replies: 13
    Last Post: 11-06-2007, 11:56 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM
  5. odd errors from msvc std library files
    By blight2c in forum C++ Programming
    Replies: 6
    Last Post: 04-30-2002, 12:06 AM

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