title: Dynamically allocate memory for Array of Structs
body: <p>Here's what I'm trying to do:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  struct myStruct {
      int myVar;
  }
  
  struct myStruct myBigList = null;
  
  void defineMyList(struct myStruct *myArray)
  {
       myStruct *myArray = malloc(10 * sizeof(myStruct));
  
       *myArray[0] = '42';
  }
  
  int main()
  {
       defineMyList(&amp;myBigList);
  }
  </code></pre>
  
  <p>I'm writing a simple C program to accomplish this. I'm using the GNU99 Xcode 5.0.1 compiler. I've read many examples, and the compiler seems to disagree about where to use the <code>struct</code> tag. Using a <code>struct</code> reference inside the <code>sizeof()</code> command doesn't seem to recognize the <code>struct</code> at all. </p>