title: Copying a 4 element character array into an integer in C
body: <p>A char is 1 byte and an integer is 4 bytes. I want to copy byte-by-byte from a char[4] into an integer. I thought of different methods but I'm getting different answers. </p>
  
  <pre><code>char str[4]="abc";
  unsigned int a = *(unsigned int*)str;
  unsigned int b = str[0]&lt;&lt;24 | str[1]&lt;&lt;16 | str[2]&lt;&lt;8 | str[3];
  unsigned int c;
  memcpy(&amp;c, str, 4);
  printf("%u %u %u\n", a, b, c);
  </code></pre>
  
  <p>Output is
  6513249 1633837824 6513249</p>
  
  <p>Which one is correct? What is going wrong? </p>