Thread: Dev C++ Executables Crash

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    1

    Dev C++ Executables Crash

    So I've just recently begun programming in C using Dev C++, but when I try and execute a program I compile with it the command prompt flashes quickly and just disappears. This happens both within the program and without.
    Here's what I'm trying to run, just the simple "Hello World" program:

    Code:
    #include <stdio.h>
    main()
    {
          printf("Hello World\n");
    }

  2. #2
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    You need to force the program to wait.
    Put this at the bottom:
    printf("Press any key to continue...");
    _getch();
    Any keystroke will satisfy this "wait" and continue the program - which promptly ends.

  3. #3
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Stop using Dev. It is obsolete, no longer supported and generally crap. Use Pelles or Codeblocks for C programming.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Chucklehofft View Post
    So I've just recently begun programming in C using Dev C++, but when I try and execute a program I compile with it the command prompt flashes quickly and just disappears. This happens both within the program and without.
    Here's what I'm trying to run, just the simple "Hello World" program:

    Code:
    #include <stdio.h>
    main()
    {
          printf("Hello World\n");
    }
    Open a command shell in your working directory and run the program from the command prompt...

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    <<< Hijack posts moved -> HJ: unresolved symbols >>>
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ and Loading Executables
    By MAniX in forum C++ Programming
    Replies: 2
    Last Post: 05-02-2006, 07:10 AM
  2. Decoding g++ executables
    By Opel_Corsa in forum Linux Programming
    Replies: 5
    Last Post: 02-20-2006, 03:03 AM
  3. Emailing executables
    By rjeff1804 in forum C Programming
    Replies: 3
    Last Post: 08-25-2004, 01:51 PM
  4. executables
    By floogyman in forum C Programming
    Replies: 2
    Last Post: 12-26-2003, 02:54 AM
  5. STL + MSVC++ = big executables ?
    By teneniel in forum C++ Programming
    Replies: 6
    Last Post: 11-04-2002, 02:12 PM