title: Why is iostream::eof inside a loop condition (i.e. `while (!stream.eof())`) considered wrong?
body: <p>I just found a comment in <a href="https://stackoverflow.com/questions/5578631/c-how-do-you-stop-reading-integer-from-text-file-when-encounter-negative-intege/5578649#5578649">this</a> answer saying that using <code>iostream::eof</code> in a loop condition is "almost certainly wrong". I generally use something like <code>while(cin&gt;&gt;n)</code> - which I guess implicitly checks for EOF.</p>
  
  <p>Why is checking for eof explicitly using <code>while (!cin.eof())</code> wrong?  </p>
  
  <p>How is it different from using <code>scanf("...",...)!=EOF</code> in C (which I often use with no problems)?</p>