title: Returning a struct pointer
body: <p>Suppose I have the following struct and function returning a pointer:</p>
  
  <pre><code>typedef struct {
    int num;
    void *nums;
    int size;
  } Mystruct;
  
  Mystruct *mystruct(int num, int size)
  { 
     //Is the following correct? Is there a more efficient way?
     Mystruct mystruct;
     mystruct.num = num;
     mystruct.size = size;
     mystruct.nums = malloc(num*sizeof(size));
     Mystruct *my;
     *my = mystruct;
     return my;
  }
  </code></pre>
  
  <p>I want to define any Mystruct pointer using the above function.  Should I declare a Mystruct variable, define the properties of Mystruct, assign a pointer to it, and return the pointer or define the properties of a mystruct property through a pointer immediately?</p>