title: Allocating memory for a 2d array of pointers wrapped within an struct in C
body: <p>Let's say I have a struct named 'Foo' and inside of that I have a 2d array of pointers</p>
  
  <pre><code>      typedef struct Foo {
            Stuff* (*stuff)[16];
        } Foo;
  </code></pre>
  
  <p>I have an initializeFoo function like so that allocates memory for the whole object</p>
  
  <pre><code>      void initializeFoo(Foo **foo) {
            *foo = (Foo*)malloc(sizeof(Foo));
        }
  </code></pre>
  
  <p>However, with just that I result in a Segmentation fault(core dumped) when running my program
  I was thinking that I need to allocate the memory for *stuff, but how would I do that? And would I stick that in the initializeFoo function?</p>
  
  <p>My guess would be to use:</p>
  
  <pre><code>    (*foo)-&gt;stuff = (Stuff*(*)[16])malloc(sizeof(Stuff))
  </code></pre>
  
  <p>Can someone help me out?</p>