title: How is memory allocated for typedef's in structs (C)
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/119123/why-isnt-sizeof-for-a-struct-equal-to-the-sum-of-sizeof-of-each-member">Why isn’t sizeof for a struct equal to the sum of sizeof of each member?</a>  </p>
  </blockquote>
  
  
  
  <p>When you create a struct in C, for example: </p>
  
  <pre><code>typedef struct student
  {
  
  int roll_no;
  char* name;
  int* pointer;
  
  
  }student;
  </code></pre>
  
  <p>I noticed that roll_no and name are not stored contiguously in memory. How does this work? If aim is to encapsulate this data, wouldn't it be better if they were stored contiguously? How does the compiler know that these pieces of data belong together?</p>