Thread: need Dev C++ help

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    16

    Question need Dev C++ help

    ok, when I compile a program with Dev C++ it saves an executable in the folder where the source file is. When I run the program it allows you to enter the input but after it calculates the output it closes immediately. Is there a way to view the output and keep the window open. Any help would be appreciated. My computer has windows 98SE.

  2. #2
    Registered User Engineer's Avatar
    Join Date
    Oct 2001
    Posts
    125
    In some compilers adding a return statement at the end of the main() usually does the trick.

    But if that doesn't work, open a MS-DOS window ( a command prompt ) and run you exe from there. This won't dissappear from your screen for sure.

    Cheers.
    1 rule of the Samurai Code: if you have nothing to say, don't say anything at all!

  3. #3
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    the simplest thing to do (requires no headers other than iostream, which you have anyway if you are outputting to screen), is

    int main() {
    // code
    char wait; cin >> wait;
    return 0;
    }

    It will wait until you press enter before closing
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    16
    this is what worked:

    system("PAUSE");
    return 0;

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    16
    this waits until you press any key before closing the program. Thanks for your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to Dev C++/<windows.h>...
    By Cilius in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2005, 01:05 AM
  2. Glut and Dev C++, Programs not Quitting?
    By Zeusbwr in forum Game Programming
    Replies: 13
    Last Post: 11-29-2004, 08:43 PM
  3. openGL programming - From MSVC++ to Dev C++
    By WDT in forum Game Programming
    Replies: 3
    Last Post: 03-08-2004, 08:47 PM
  4. openGL programming - From MSVC++ to Dev C++
    By WDT in forum Game Programming
    Replies: 1
    Last Post: 03-08-2004, 05:19 PM
  5. DEV C++ Limitations?
    By Kirdra in forum Game Programming
    Replies: 3
    Last Post: 09-09-2002, 09:40 PM