title: How can I read the first number of a file?
body: <p>I am trying to read numbers from a file and put those numbers into an array. And now the file looks like this:</p>
  
  <p>100</p>
  
  <p>0 1 2 3 4 5 6 7 8 9 </p>
  
  <p>10 11 12 13 14 15 16 17 18 19 </p>
  
  <p>20 21 22 23 24 25 26 27 28 29 </p>
  
  <p>Obviously the first number is the size of the array. While I try to test the read, I got 8. And here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main()
  {
      FILE * filePtr;
      int firstNum;
      filePtr = fopen("array,dat", "r");
      if(filePtr!=NULL)
      {
      fscanf(filePtr, "%d", &amp;firstNum);
      fclose(filePtr);
      }
      printf("size: %d", firstNum);
  
  
      return 0;
  }
  </code></pre>
  
  <p>and this is the result I got:</p>
  
  <pre><code>size: 8
  Process returned 0 (0x0)   execution time : 0.012 s
  Press any key to continue.
  </code></pre>
  
  <p>So how can I get the correct number that I want and why does it show 8?</p>