title: C: char bigger than one byte?
body: <p>I'm reading a buffer of type <code>char</code> from a microcontroller device like this:</p>
  
  <pre><code>char data_buffer[DATA_LEN];
  FILE *aq_dev = fopen(argv[1], "r");
  
  fread(data_buffer, 1, DATA_LEN, aq_dev);
  
  fclose(aq_dev);
  </code></pre>
  
  <p>In this buffer blob there are unsigned 16bit integer numbers, each distributed over two entries in the buffer. For example there is</p>
  
  <pre><code>data_buffer[10] = 0x07
  data_buffer[11] = 0xc3
  </code></pre>
  
  <p>which I would like to read out as <code>0x07c3</code> which equals 1987. Despite the fact that I originally thought I could just access the buffer with a <code>uint16_t</code> pointer and directly read the value, I have to do some strange bitmasking:</p>
  
  <pre><code>int value = (buffer[10] &lt;&lt; 8) + buffer[11];
  </code></pre>
  
  <p>gives a <strong>wrong value</strong> beyond 35000 while a seemingly useless bitmasking like</p>
  
  <pre><code>int value = ((buffer[10] &amp; 0xff) &lt;&lt; 8) + (buffer[11] &amp; 0xff);
  </code></pre>
  
  <p>returns the <strong>correct value</strong>.</p>
  
  <p><strong>How can an entry of an array of <code>char</code> be bigger than one byte?</strong>
  According to my <code>limits.h</code> (Linux, x86_64) there is <code>#define CHAR_BIT 8</code>.</p>
  
  <p>Can someone please tell me what is wrong with my code? Thanks in advance!</p>