Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Program executes, but close split second later.

StuckyStucky Member Posts: 7
It's doing exactly what the title says. I use Nano in Cygwin to make the code. Then I use GCC to compile it. It comes out with the a.exe file like always. But when I try to run the program using windows explorer the window opens and then closes a split second later, I can barely even see what's printed on the screen. I'm 100% sure the program doesn't have any errors, because I've double checked it, triple checked, and I copied it straight from the book "C Programming for Absolute Beginners". It might be able to run if I start it up with the command prompt in Cygwin. But I've tried that with the "run" command and nothing happens. Please help me.

Comments

  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    : It's doing exactly what the title says. I use Nano in Cygwin to make
    : the code. Then I use GCC to compile it. It comes out with the a.exe
    : file like always. But when I try to run the program using windows
    : explorer the window opens and then closes a split second later, I
    : can barely even see what's printed on the screen. I'm 100% sure the
    : program doesn't have any errors, because I've double checked it,
    : triple checked, and I copied it straight from the book "C
    : Programming for Absolute Beginners". It might be able to run if I
    : start it up with the command prompt in Cygwin. But I've tried that
    : with the "run" command and nothing happens. Please help me.
    :

    Try opening a DOS command window and running it... or put a 'pause' at the end of the code (like waiting for input).

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • unixfreakunixfreak Member Posts: 9
    uat the very end before exit or return;
    use
    getchar();
    the command line will wait for you to enter any char and this goes to stack, so you dont have to worry about it
  • da_comp_guyda_comp_guy Member Posts: 37
    : uat the very end before exit or return;
    : use
    : getchar();
    : the command line will wait for you to enter any char and this goes
    : to stack, so you dont have to worry about it
    :
    yes .. in fact if u want it 2 b a bit more user friendly ... use [code] system("PAUSE"); [code]
    this function is in the or in some platforms.
    or u can go for the old way of using getch() at the end of the source ...
    cya !

    "[b]The[blue] GEEK[/blue] Shall Inherit The Earth" ;-) [/b]
  • StuckyStucky Member Posts: 7
    Thanks for all your help, but I need something else. I tried everything except opening it in DOS. Could someone please direct me to a good DOS emulator for Windows XP service pack 2.
Sign In or Register to comment.