title: Defining a Structure in C with Malloc
body: <p>I asked a <a href="https://stackoverflow.com/questions/2177391/allocating-memory-for-a-structure-in-c">question earlier</a> on defining a structure using malloc.
  This was the answer I was given by the majority:</p>
  
  <pre><code>struct retValue* st = malloc(sizeof(*st));
  </code></pre>
  
  <p>I was showing a friend my code, and we came to a stumbling block.
  Could someone please explain why this code works? 
  From my viewpoint, *st hasn't been defined when you malloc it, so there could be any kind of garbage in there. It should be <code>malloc(sizeof(struct retValue))</code> </p>
  
  <p>Thanks for any help</p>