title: Reading from file does not work as expected with fscanf
body: <p>I have this file:</p>
  
  <pre><code>0 -&gt; 1:50 2:30 3:10
  1 -&gt;
  2 -&gt; 0:10 3:20
  3 -&gt; 1:20 2:10 3:30
  </code></pre>
  
  <p>And I want to extract all the numbers from the file with this code:</p>
  
  <pre><code>int a, b, c;
  while (fscanf(fp, "%d -&gt;", &amp;a) == 1) {
      printf("%d -&gt;", a);
      while (fscanf(fp, " %d:%d", &amp;b, &amp;c) == 2) {
          printf(" %d:%d", b, c);
      }
      printf("\n");
  }
  </code></pre>
  
  <p>The idea is that on the first loop it will scan the first number followed by space followed by -> and then the inner loop will scan the following sequence of " %d:%d" until the end of line which will then make the outer loop return 1 because it could successfully read "%d ->". </p>
  
  <p>Ouput of code:               </p>
  
  <pre><code>0 -&gt; 1:50 2:30 3:10
  </code></pre>
  
  <p>It seems like it doesn't work as expected, and the outer while loop exits when it tried to read the number 1 from the second line(but it should?). I just find this weird because I've done something similar recently and it was working fine.</p>
  
  <p>After removing the loops and replacing with this code I get the correct results so it had something to do with my loops:</p>
  
  <pre><code>fscanf(fp, "%d -&gt;", &amp;a);
  fscanf(fp, " %d:%d", &amp;b, &amp;c);
  fscanf(fp, " %d:%d", &amp;b, &amp;c);
  fscanf(fp, " %d:%d", &amp;b, &amp;c);
  fscanf(fp, "%d -&gt;", &amp;a);
  fscanf(fp, "%d -&gt;", &amp;a);
  fscanf(fp, " %d:%d", &amp;b, &amp;c);
  fscanf(fp, " %d:%d", &amp;b, &amp;c);
  fscanf(fp, "%d -&gt;", &amp;a);
  fscanf(fp, " %d:%d", &amp;b, &amp;c);
  fscanf(fp, " %d:%d", &amp;b, &amp;c);
  fscanf(fp, " %d:%d", &amp;b, &amp;c);
  </code></pre>