title: Read integers from file and ignore whitespace in C
body: <p>I'm learning C, and part of a program I'm writing in C is to check whether my txt file contains less than or more than 81 values, and if all of the values are integers. I use fscanf to read value from file, but it also reads whitespace. How can I ignore whitespaces and make it read only integers or characters?</p>
  
  <p>My code returns 162, which contains 81 integers and whitespaces.</p>
  
  <p>This is the txt file:</p>
  
  <pre><code>1 2 3 4 5 6 7 8 9
  2 3 4 5 6 7 8 9 1
  3 4 5 6 7 8 9 1 2
  4 5 6 7 8 9 1 2 3
  5 6 7 8 9 1 2 3 4
  6 7 8 9 1 2 3 4 5
  7 8 9 1 2 3 4 5 6
  8 9 1 2 3 4 5 6 7
  9 1 2 3 4 5 6 7 8
  
  
  #include&lt;stdio.h&gt;
  
  int main() {
  FILE * input_values;
  
  input_values = fopen("text.txt","r");
  
      if (input_values == NULL) {
          fprintf(stderr, "Error! Could not open file.\n");
      }
  
  int ch, counter = 0;
  
  ch = fscanf(input_values, "%d");
      while (ch != EOF) {
              counter++;
              ch = fscanf(input_values, "%d");
      }
  
      printf("num %i",counter);
      fclose(input_values);
  
  }
  </code></pre>