title: How does fscanf interact with the file it parses information from?
body: <p>I am kinda new to C, have written some basic programs, but other than that I know nothing special. Currently I am writing a program that needs to get its variables from a .txt file. The .txt file is always structured like this:</p>
  <pre><code>X Y             //1st row
  a1 a2 a3 a4 aX  //2nd row
  </code></pre>
  <p>Where the number of a's I am getting equals the number X.(Everything in the file is an int)<br />
  The bit in my code that confuses me is this:</p>
  <pre><code>fscanf(txtfile,&quot;%d %d&quot;,&amp;X,&amp;Y);
      int input[X];                                                           
      for(int i=0; i&lt;X; i++){
              fscanf(txtfile,&quot;%d&quot;,&amp;input[i]);
      }  
  </code></pre>
  <p>Which works perfectly fine, but in my mind it shouldn't...<br />
  I thought that after getting X and Y from my .txt file, the fscanf in the loop would go through them again and I would have to find a way to bypass them, so they don't end up in my input[]. I was going to make a dummy array to store the first two ints and then transfer the other ones to the proper one, but it turned out that the dummy array worked just fine and the &quot;proper&quot; one ended with garbage in it. So what does actually happen? Does fscanf have some kind of pointer on the file that tells it where it stopped the last time it run? Or something completely different? I tried going through the man pages for fscanf, but i didn't find anything useful, or maybe it just went over my head.<br />
  P.S. The title may be a little bit off in regards to what I am asking, but I couldn't think of a better one.<br />
  Thanks for your time!</p>