title: Using fgetc with stdin pointer. Error handling input
body: <p>I just want to ask why on my function <code>read_int</code> does not accept my input from <code>fgetc</code> as <code>int</code>? (I figured that is the case because I always input an integer yet it still go to my <code>int</code> function that displays error.</p>
  
  <p>Here's my code (with skel code from my prof):</p>
  
  <pre><code>int main() {
      int the_int;
      double the_double;
      printf("Doing tests of read_int and read_double functions ...\n\n");
      printf("Please try to enter an int: ");
      the_int = read_int();
      printf("read_int succeeded.  It read a value of %d.\n", the_int);
      printf("Please try to enter a double: ");
      the_double = read_double();
      printf("read_double succeeded.  It read a value of %g.\n", the_double);
      return 0;
  }
  
  int read_int(void) {
      int f = fgetc(stdin);
      if (fgetc(stdin) != EOF) {
          printf("Sorry that is invalid.");
          exit(1);
      }
      return f;
  }
  </code></pre>