title: Difficulty using file.seekg() (C++)
body: <p>The following code only prints the file once:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  int main(int argc, const char *argv[])
  {
      ifstream infile;
      infile.open("in", ios::binary);
      char c;
  
      while (infile.get(c))
      {
          cout &lt;&lt; c;
      }
  
      infile.seekg(0, ios::beg);
      infile.clear();
  
      while (infile.get(c))
      {
              cout &lt;&lt; c;
      }
      infile.close(); 
      return 0;
  }
  </code></pre>
  
  <p>I assume it has something to do with the eof flag after running through the file, but I don't know how to fix that.</p>
  
  <p>Cheers.</p>