title: Memory alignment in C-structs
body: <p>I'm working on a 32-bit machine, so I suppose that the memory alignment should be 4 bytes. Say I have this struct:</p>
  <pre><code>typedef struct {
      unsigned short v1;
      unsigned short v2;
      unsigned short v3;
  } myStruct;
  </code></pre>
  <p>The plain added size is 6 bytes, and I suppose that the aligned size should be 8, but <code>sizeof(myStruct)</code> returns me 6.</p>
  <p>However if I write:</p>
  <pre><code>typedef struct {
      unsigned short v1;
      unsigned short v2;
      unsigned short v3;
      int i;
  } myStruct;
  </code></pre>
  <p>the plain added size is 10 bytes, aligned size shall be 12, and this time <code>sizeof(myStruct) == 12</code>.</p>
  <p>Can somebody explain what is the difference?</p>