Menu

Program compiles, but executable a no-show

Billy
2009-07-05
2012-09-26
  • Billy

    Billy - 2009-07-05

    I have Dev-C++ version 4.9.9.2 and Windows XP Pro SP3. I having no trouble compiling but I am having trouble getting my executable to show up. It flashes and then goes away.

    My Compile Log reads like so:

    Compiler: Default compiler
    Executing gcc.exe...
    gcc.exe "C:\programming\first.c" -o "C:\programming\first.exe"
    Execution terminated
    Compilation successful

    My program is extremely basic, like so:

    include <stdio.h>

    main()

    {

    int people, places, things;

    people = 5;
    places = 4;
    things = 3;

    printf("There are %d people, %d places to visit, and %d things to kill", people, places, things);

    }

    Thanks a ton for any advice. As a newb to programming somewhat, this is probably an extremely simple fix, but after some searching I couldn't find my exact problem answered. Probably pretty close though, but I figured I might as well confirm it with 1337 SOB's here. :)

     
    • Billy

      Billy - 2009-07-05

      Well, I finally figured it out. I just add "getchar();". That was simple as hell. I wonder if because my C programming book is 8 years old (2001 copyright of a 1998 book called "Beginning C" by Ivor Horton) that maybe somehow leaving that out a decade ago wasn't a big deal but today it's relevant? You guys don't have to answer that, I'll do my own research, but any pithy comments are always welcome. :)

       
    • cpns

      cpns - 2009-07-06

      The 'problem' is that the normal behaviour of Windows is to close an application's window when the application terminates. You'd hardly want it any other way, but it seems to surprise people when it happens to their own applications!

      The problem is so common it is dealt with in the "PLEASE READ BEFORE POSTING A QUESTION" thread, so it is lucky that you figured it out and posted back, and probably saved yourself a flaming! ;-)

      Some IDE's (VC++ for example) execute projects in a wrapper that holds the console open. It is a simple thing to do, and useful for development, but the developers of Dev-C++ have chosen not to do it for some reason.

      Note that using getchar() is not always the best solution. Any unused lines in the input line-buffer will cause it to return without waiting.

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.