title: Does fscanf moves the passed file pointer ahead?
body: <p>I saw this code somewhere:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main()
  {
      FILE * fp;
      char s[1024];
      fp = fopen("file","r");
  
      while( fscanf(fp, "%s", s ) != EOF )
      {
          puts(s);
      }
  
    return 0;
  }
  </code></pre>
  
  <p>I expected that this will keep on printing the first word of the file in an infinite loop. I believed that file pointer is taken as input only to get the point from where input should be read and fscanf would have a local file pointer which it would use to read the file.</p>
  
  <p>But on running I realized it actually prints the whole file. Only conclusion I can draw is that after reading the first input, it actually moves the passed file pointer ahead, otherwise it would have just kept on printing the first word again and again.</p>
  
  <p>I saw the <a href="http://www.manpagez.com/man/3/fscanf/" rel="nofollow"> man documentation</a> of fscanf but couldnt find anything regarding movement of file pointer after reading.</p>
  
  <p>Can someone please explain or give a source where it is specified that the passed file pointer actually moves after reading ?</p>