title: How to implement a 2-dimensional array of struct in C
body: <p>I'm currently trying to understand how to implement a 2-dimensional array of struct in C. My code is crashing all the time and I'm really about to let it end like all my approaches getting firm to C: garbage. This is what I got:</p>
  
  <pre><code>typedef struct {
      int i;
  } test;
  
  test* t[20][20];
  *t = (test*) malloc(sizeof(test) * 20 * 20);
  </code></pre>
  
  <p>My glorious error: </p>
  
  <blockquote>
    <p>error: incompatible types when assigning to type ‘struct test *[20]’ from type ‘struct test *’</p>
  </blockquote>
  
  <p>Do I have to allocate the memory seperately for every 2nd dimension? I'm getting nuts. It should be so simple. One day I will build a time-machine and magnetize some c-compiler-floppies...</p>