title: Need a two-dimensional array of "variable" size in a struct
body: <p>I am attempting to implement a grid of cells, analogous to that of Conway's game of life.</p>
  
  <p>While each individual grid should have fixed size in both dimensions, I would like a Grid struct that allows for any size in both dimensions.</p>
  
  <p>This is in analogy to how arrays can be of any size, but an array once initialized has a fixed size.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>typedef struct Cell {
      int data;
      // stuff to be added later
  } Cell;
  
  typedef struct Grid {
      unsigned width;
      unsigned height;
      Cell cell[][];
  } Grid;
  
  Grid initGrid(unsigned width, unsigned height) {
      Grid g;
      g.width = width;
      g.height = height;
      g.cell = malloc( sizeof(Cell)*width*height );
      return g;
  }
  </code></pre>
  
  <p>However I get the following compile-time error:</p>
  
  <pre><code>main.c|12|note: declaration of `‘cell’ as multidimensional array must have bounds for all dimensions except the first|
  </code></pre>
  
  <blockquote>
    <p>How can I define a <code>Grid</code> data type with flexible size?</p>
  </blockquote>
  
  <p>Post scriptum: as a C newbie, I thought the following would work:</p>
  
  <pre><code>typedef struct Grid {
      unsigned width;
      unsigned height;
      Cell cell[width][height];
  } Grid;
  </code></pre>
  
  <p>Post post scriptum: I am always uneasy whenever I use <code>malloc</code>. Am I doing (or trying to do) anything horribly wrong here?</p>