title: How to read unsigned short from file?
body: <p>I have a bitmap image that I am parsing and I need to be able to open the file and store the first unsigned short.</p>
  
  <p>I tried to accomplish this using FILE and fscanf() but fscanf() always fails and returns 0 (number of items successfully read).</p>
  
  <pre><code>FILE *pFile = fopen ( fileName-&gt;c_str() , "r" );
  
  if ( pFile == NULL )
  {
      cerr &lt;&lt; "couldn't open file ; exiting..." &lt;&lt; endl;
      exit(0);
  }
  
  unsigned short seed;
  fscanf (pFile, "%hu", &amp;seed);
  </code></pre>
  
  <p>Does anyone know of another approach I could take (possibly ifstream?) or maybe could just give me some pointers?  Any help would be greatly appreciated.</p>
  
  <p>Thank you.</p>