title: converting uint8_t[4] to uint32_t and back again in C
body: <p>I wrote this test to convert a <code>uint8[4]</code> into a <code>uint32_t</code>, but how would I convert the output of <code>u32</code> back to the original <code>uint8[4]</code>? I assume it can be done the same way via bit shifting, but i'm not sure how...</p>
  
  <pre><code>uint32_t u32(uint8_t b[4]){
    uint32_t u;
    u = b[0];
    u = (u  &lt;&lt; 8) + b[1];
    u = (u  &lt;&lt; 8) + b[2];
    u = (u  &lt;&lt; 8) + b[3];
    return u;
  }
  
  void p(uint32_t value){
          printf("\nuint32: %u\n",value);
  }
  
  int main(){
   uint8_t b[4];
   char a[4] = "test";
   char tmp[32];
  
   int i;
   for(i=0;i&lt;4;i++){
     b[i] = a[i];
     sprintf(tmp,"%s%u",tmp,b[i]);
   }
  
   printf("uint8: ");
  
   for(i=0;i&lt;4;i++)
     printf("%u",b[i]);
  
  uint32_t t2 = u32(b);
   p(t2);
   return 0;
  }
  </code></pre>