title: Why can't I read fstream's binary data with operator>>?
body: <p>If I do something like the following:</p>
  
  <pre><code>ifstream file;
  file.open("somefile", ios::binary);
  
  unsigned int data;
  
  file &gt;&gt; data;
  </code></pre>
  
  <p>My stream will always set the <code>failbit</code> and the <code>data</code> will remain uninitialized.  However, if I read a <code>char</code> or <code>unsigned char</code> instead, the stream is fine.  <code>perror()</code> is telling me "result too large".  </p>
  
  <p>The only thing I saw on Google was a suggestion saying that <code>operator&gt;&gt;</code> shouldn't be used for binary data (prefer <code>read()</code>), but I find the operator to be cleaner and easier to use -- and it doesn't require casting everything.</p>
  
  <p>Can someone explain this issue?</p>