Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Help with Basic C Programing Closing (http://www.go4expert.com/forums/help-basic-c-programing-closing-t7414/)

AKalair 20Nov2007 21:51

Help with Basic C Programing Closing
Im learning C and currently going through the tutorials on Cprogramming.com. However when I compile there second 'example' I enter a number and it closes too quick to read the output. If I run it in debug mode on Bloodshed Dev c++ it stays open and I can read the output. Ive tried adding things like return 0; to the end but im new to this and it never made a difference can anyone help me get the window to stay open?

Code: C

#include <stdio.h>

int main()
  int this_is_a_number;

  printf( "Please enter a number: " );
  scanf( "%d", &this_is_a_number );
  printf( "You entered %d", this_is_a_number );

The tutorial im using is here: Click Me

Thank you in advance.

shabbir 20Nov2007 23:14

Re: Help with Basic C Programing Closing
Just try putting the fflush function before the last getchar function.

All times are GMT +5.5. The time now is 09:19.