title: C - How to convert int values into a binary uint8 message
body: <p>So I have the following Int Array with 5 values</p>
  
  <pre><code>int guess[5]= { 1 , 4 , 7 , 3 , 0 } // Testguess
  </code></pre>
  
  <p>What I want to have in the end is a uint16, or actually 2 uint8 values representing those values in binary. The LSB (bit 15) is used for a flag which is irrelevant for now. In the end I want to transfer this message via a socket.</p>
  
  <p>So with the values stated above I want to get the following message:
  (I will seperate the different values with spaces to make it more clear)</p>
  
  <p><code>X 000 011 111 100 001</code></p>
  
  <p>Note that the values are from right to left.</p>
  
  <p>The X is a flag, which is basically a xor with all bits, but I think I can figure this out for myself.</p>
  
  <p>I am pretty new to C and want to know good solutions for the following tasks.</p>
  
  <ul>
  <li>How to convert the values of the int Array into binaries?</li>
  <li>How to write those binary values into the uint16?</li>
  <li>How to split this result uint16 into 2 uint8s?</li>
  </ul>
  
  <p>I am pretty much failing finding a good approach to this. I was thinking about using shifts with the range of 3 for the writing, but I am not sure how to get those binaries, maybe doing &amp; 0x2 or something?</p>
  
  <p>Like I said I am still pretty new to C and am happy for every help.</p>