title: Size of C Structure containing char
body: <p>I have defined 2 structures in C Language, both contains 2 ints and 1 char. When I print size of both of them, its giving results I can't justify. This is my code :</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  struct sample
  {
      int a:6;
      int b:12;
      char s;
  } st;
  struct name
  {
      int a:28;
      int b:12;
      char ch;
  } st1;
  
  int main()
  {
      int i=sizeof(st);
      printf("st : %d\n\n",i);
  
      i=sizeof(st1);
      printf("st1 : %d\n\n",i);
  }
  </code></pre>
  
  <p>output is :</p>
  
  <pre><code>st : 4
  st1 : 8
  </code></pre>
  
  <p>How the size of st is 4 byte and st1 is 8 bytes?</p>
  
  <p>I found this <a href="https://stackoverflow.com/questions/7105403/size-of-c-structure">similar question</a> but the values I am getting are still not justified. According to this question, my structure st should be taking 3 bytes and st1 should be taking 6 bytes. </p>