title: Sizeof Structure in C
body: <p>To find the size of a structure in C</p>
  
  <p><pre>
  struct student
      {
       char name;
       int age;
       float weight;
      };</p>
  
  <p>main ()
  {
      int i,j,k,l;
      struct student s1;
      i=sizeof(s1.name);
      j=sizeof(s1.age);
      k=sizeof(s1.weight);
      l=sizeof(s1);
      printf ("\n size of name    %d",i);
      printf ("\n size of age     %d",j);
      printf ("\n size of weight  %d",k);
      printf ("\n size of s1      %d",l);</p>
  
  <code>printf("\n");
  }
  </code></pre>
  
  <p>My output is:</p>
  
  <p><code>size of name    1
   size of age     4
   size of weight  4
   size of s1      12
  </code></p>
  
  <p>But structure size should be the sum of sizes of its members. Why am i getting 12 instead of 9 as size of structure variable s1. Can someone explain what is wrong.</p>