Help with Dev-c++

Discussion in 'Programmer's Corner' started by Jrockcapri78, Dec 1, 2007.

  1. Jrockcapri78

    Thread Starter New Member

    Nov 9, 2007
    9
    0
    I just finished writing a program in C using Dec-c++, but when I compile and run the window opens and closes before I can use the program. Is there anything I can do to keep the window open?
     
  2. Salgat

    Active Member

    Dec 23, 2006
    215
    1
    I forgot the exact name of the command since I haven't used C in forever, but use a command that asks for an input at the end. That will pause the program before it closes.
     
  3. Ryno3030

    New Member

    Dec 1, 2007
    9
    0
    Salgat is correct. When running c++ programs in the Windows environment, the program runs fine and closes when it is complete. Adding a simple cin>> statement to a variable at the end will pause the program until you enter a value. This will allow you to see any other output from your program as long as you like.
     
  4. Jrockcapri78

    Thread Starter New Member

    Nov 9, 2007
    9
    0
    Thanks, got it to work
     
  5. omnispace

    Member

    Jul 25, 2007
    27
    0
    You can also use system("pause"), I think it's in cstdlib.h.
     
  6. cumesoftware

    Senior Member

    Apr 27, 2007
    1,330
    10
    You can also run you console program from the command line. Just put a batch file containing the line "cmd.exe" (or "command.com" if you are using Windows 95/98) in the same folder of the compiled executable. Thus you can test your program without alterations.

    Dev-C++ is a great compiler. I think it uses the same assembler as DJGPP (GCC - GNU Compiler Colection).
     
Loading...