title: Read two files from stdio
body: <p>I want to read from two files, one containing floats in three columns, and another containing ints in two columns. I have the following code to read from stdin:</p>
  
  <pre><code>int main() {
      while (scanf("%lf %lf %lf\n",&amp;x,&amp;y,&amp;z) != EOF) {
          // do stuff
      }
  
      puts("foo");
  
      int a,b;
      while (scanf("%d %d\n",&amp;a,&amp;b) != EOF) {
          puts("bar");
      }
  }
  </code></pre>
  
  <p>Then I call the program with <code>cat ortho.dat pairs.dat | ./angles</code>, ortho.dat and pairs.dat being the two files. However the output is just <code>foo</code> indicating that the second file is never read, presumably because it reads EOF and immediately terminates the second loop. Is this correct?</p>
  
  <p>How could I read the two files, without actually opening them in the program, merely reading them from stdin?</p>