title: reading uint16_t from bit stream
body: <p>I'm attempting to read a uint16_t from a u_char stream pointer (which happens to point to an ip header) but am having some difficulty getting a rational result.</p>
  
  <p>Right now when I run:</p>
  
  <pre><code>uint16_t len16 = *stream;
  </code></pre>
  
  <p>or when I run the following, in case there is a discrepancy between the network and host byte order:</p>
  
  <pre><code>uint16_t len16 = *stream;
  len16 = ntohs(len16);
  </code></pre>
  
  <p>I do not get the expected result in the uint16_t. However when I run:</p>
  
  <pre><code>uint8_t total_len1, total_len2;
  uint16_t total_len;
  
  //get length1
  total_len1 = *stream;
  
  //advance pointer
  stream += sizeof(uint8_t);
  
  //get length2
  total_len2 = *stream;
  
  //advance pointer
  stream += sizeof(uint8_t);
  </code></pre>
  
  <p>I get the results I am expecting in total_len1 and total_len2 in hex format. So what is going on here and how can I read this value directly into a uint16_t?</p>