title: Differences between eof and fail
body: <p>I know, there was hundreds questions about fail and eof, but no one was able to answered my question.
  In this example, only eof bit will be set:</p>
  
  <pre><code>while (!Ifstream.eof()){
      Ifstream &gt;&gt; Buffer;
      cout &lt;&lt; Buffer &lt;&lt; endl;
  }
  </code></pre>
  
  <p>But in this example, eof bit as well as fail bit will be set:</p>
  
  <pre><code> while (!Ifstream.fail()){
      Ifstream &gt;&gt; Buffer;
      cout &lt;&lt; Buffer &lt;&lt; endl;
  }
  </code></pre>
  
  <p>What is the reason of this two differences? .I consider only situation, when stream reach end of file.</p>