title: Binary file read different results for amount of bytes read at a time
body: <p>I am reading binary data from a file, however reading one byte at a time gives expected results, while reading anymore than one byte at a time does not. Reading one at a time:</p>
  
  <pre><code>void readFile(){
          std::ifstream in;
          in.open("file.bin", std::ios:binary);
  
          uint8_t byte1;
          uint8_t byte2;
          in.read(reinterpret_cast&lt;char *&gt;(&amp;byte1), sizeof(byte1));
          in.read(reinterpret_cast&lt;char *&gt;(&amp;byte2), sizeof(byte2));
  
          std::cout &lt;&lt; std::bitset&lt;8&gt;(byte1) &lt;&lt; std::bitset&lt;8&gt;(byte2);
  }
  </code></pre>
  
  <p>This produces the expected output of</p>
  
  <pre><code>0000101000000110
  </code></pre>
  
  <p>Reading two at a time:</p>
  
  <pre><code>void readFile(){
          std::ifstream in;
          in.open("file.bin", std::ios:binary);
  
          uint16_t twobytes;
          in.read(reinterpret_cast&lt;char *&gt;(&amp;twobytes), sizeof(twobytes));
  
          std::cout &lt;&lt; std::bitset&lt;16&gt;(twobytes);
  }
  </code></pre>
  
  <p>Produces unexpected output of</p>
  
  <pre><code>0000011000001010
  </code></pre>