title: using one ifstream variable for reading several files
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2284775/c-can-i-reuse-fstream-to-open-and-write-multiple-files">C++ can I reuse fstream to open and write multiple files?</a>  </p>
  </blockquote>
  
  
  
  <p>why is it not possible to use one ifstream variable for opening one file, reading it, then closing it and, after that, opening another file, reading and closing, etc?
  How would that look in code (let's just say each file has an integer inside):  </p>
  
  <pre><code>int k, l;  
  ifstream input1;  
  input1.open("File1.txt");  
  input1 &gt;&gt; k;  
  input1.close();  
  input1.open("File2.txt");  
  input1 &gt;&gt; l;  
  input1.close(); 
  </code></pre>
  
  <p>the only way I solved the problem was creating another ifstream variable.</p>