title: Struct Memory Allocation in C
body: <p>Does allocating a <code>struct</code> instance using <code>malloc</code> have any effect on the allocation of its members? Meaning that, is doing something like this:</p>
  
  <pre><code>typedef struct { int *i; } test;
  int main() {
       test *t = malloc(sizeof(test));
       t-&gt;i = malloc(sizeof(int));
  }
  </code></pre>
  
  <p>... is meaningless because <code>i</code> should be already on the heap, right ?</p>
  
  <p>Or, the struct is just conceptual to help the programmer group two completely separate variables floating in memory? Meaning that: <code>test *t = malloc(sizeof(test))</code> just allocates the memory for storing pointers to the members on the heap?</p>
  
  <p>I'm quite baffled about this ..</p>