dos closes right away after executing

This is a discussion on dos closes right away after executing within the C++ Programming forums, part of the General Programming Boards category; program runs when i run through compiler & also when I run it from a DOS window. But when I ...

  1. #1
    Unregistered
    Guest

    dos closes right away after executing

    program runs when i run through compiler & also when I run it from a DOS window.
    But when I go to run the .exe from the Debug folder (is this where you generate the .exe btw), it opens DOS & closes right away.!

    Pls help ASAP.. Thanks!

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    69

    Solution

    There are 2 ways to fix it 1. you use Ms Dos Prompt or you can add this to your program you need to #include <stdlib.h> and just before the end of the program add system("PAUSE");
    This'll pause the program.

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

  4. #4
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    you could also use the getch() fuction in conio.h as the last line of the code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Executing DOS commands from inside an image
    By Moony in forum C Programming
    Replies: 6
    Last Post: 03-16-2008, 12:40 PM
  2. Executing DOS command in C
    By m.sudhakar in forum C Programming
    Replies: 3
    Last Post: 07-22-2006, 02:52 PM
  3. MS DOS Window closes right away!
    By poolshark1691 in forum C++ Programming
    Replies: 5
    Last Post: 05-24-2005, 11:35 AM
  4. Dos Window closes after I press enter
    By ProgrammingDlux in forum C++ Programming
    Replies: 4
    Last Post: 01-24-2002, 11:13 AM
  5. my dos closes at once
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 10-21-2001, 01:54 AM

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