Program executes, but close split second later.

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

  • : 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
  • 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
  • : 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]
  • 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.

Howdy, Stranger!

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

Categories