title: Copying array to a structure
body: <p>I have an array of 9 bytes and I want to copy these bytes to a structure :</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;string.h&gt;
  
  typedef struct _structure {
      char one[5];        /* 5 bytes */
      unsigned int two;   /* 4 bytes */
  } structure;
  
  int main(int argc, char **argv) {
  
      structure my_structure;
  
      char array[]    = {
          0x41, 0x42, 0x43, 0x44, 0x00,   /* ABCD\0 */
          0x00, 0xbc, 0x61, 0x4e          /* 12345678 (base 10) */
      };
  
      memcpy(&amp;my_structure, array, sizeof(my_structure));
  
      printf("%s\n", my_structure.one);   /* OK, "ABCD" */
      printf("%d\n", my_structure.two);   /* it prints 1128415566 */
  
      return(0);
  }
  </code></pre>
  
  <p>The first element of the structure <code>my_structure</code>, <code>one</code>, is copied correctly; however, <code>my_structure.two</code> contains 1128415566 while I expect 12345678. <code>array</code> and <code>my_structure</code> have different sizes and even if they are equal in size, still there will be a problem with <code>two</code> . How can I fix this issue?</p>