fork download
  1. #include<stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int checkInput( void );
  5.  
  6. int main( void )
  7. {
  8. int number = checkInput( );
  9.  
  10. printf( "\nYour number is\t%d\n", number );
  11.  
  12. return 0;
  13. }
  14.  
  15. int checkInput( void )
  16. {
  17. int option,check;
  18. char c;
  19. int count = 3;
  20.  
  21. do{
  22. printf("Please type a number:> ");
  23.  
  24. if( scanf( "%d%c", &option, &c ) == 0 || c != '\n' )
  25. {
  26. while( ( check = getchar() ) != 0 && check != '\n' );
  27. if ( count > 0 )
  28. {
  29. printf( "\tI sayed a Number please\n" );
  30. printf( "\tYou have %d more tries\n\n", count-- );
  31. }
  32. else
  33. {
  34. printf( "\n\n\tToo many wrong Inputs\tGoodbye.\n" );
  35. exit( EXIT_FAILURE );
  36. }
  37. }
  38. else
  39. {
  40. break;
  41. }
  42. }while( 1 );
  43.  
  44. return option;
  45. }
Time limit exceeded #stdin #stdout 5s 9424KB
stdin
Standard input is empty
stdout
Standard output is empty