title: Is it possible to typedef a multidimensional array of uncertain size? [C]
body: <p>I am trying currently to solve a specific task. For this task I try to exercise all the skills I have learned so far. Since I am dealing with a multidimensional array a lot I wanted to typedef it as usual.</p>
  
  <p>This time the array has to be editable by the program in size.</p>
  
  <pre><code>typedef char grid[][];
  </code></pre>
  
  <p>this is what I tried in my special header file. I am getting the error </p>
  
  <pre><code>error: array type has incomplete element type
  </code></pre>
  
  <p>I post the complete code if it is necessary to see more details:</p>
  
  <p>main.c </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;assert.h&gt;
  #include "functions.h"
  #include "tester.h"
  #include "magic.h"
  
  int main(int argc, char **argv)
  {
      int size = getSize();
      grid pascal[size][size];
      drawGrid(pascal, size);
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>functions.c</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include "magic.h"
  #include &lt;math.h&gt;
  
  /*  C array: Pascal triangle exercise
  *  By using two-dimensional array, write C program to display
  *  a table that represents a Pascal triangle of any size.
  *
  *  In Pascal triangle, the first and the second rows are set to 1.
  *  Each element of the triangle (from the third row downward) is the sum
  *  of the element directly above it and the element to the left of the
  *  element directly above it. See the example Pascal triangle(size=5) below:
  *
  *
  *  1
  *  1    1
  *  1    2   1
  *  1    3   3   1
  *  1    4   6   4   1
  *
  */
  
  int getSize(void)
  {
      int size;
      printf("Please enter the size of the Pascal Triangle:");
      scanf("%d",&amp;size);
      printf("\n");
  
      size = (int) sqrt(size);
      printf("Pascal Triangle will be %d big", (size*size));
      return size;
  }
  
  void createVoid(grid pascal, int size)
  {
      int i = 0;
      int j = 0;
  
      while(i &lt; size){
          while (j &lt; size){
              if (j &gt; i){
                  pascal[i][j] = ' ';
              }
              j++;
         }
         i++;
      }
  }
  
  void createNumbers(grid pascal, int size)
  {
      int i = 0;
      int j = 0;
  
      while(i &lt; size){
          while (j &lt; size){
              if (j &lt;= i){
                  if (i == 0){
                      pascal[i][j] = '1';
                  }else if (i == j){
                      pascal[i][j] = '1'
                  }else{
                      pascal[i][j] = pascal[i][j-1] - VALUE_ZERO + pascal[i-1][j];
                  }
              }
              j++;
          }
          i++;
      }
  }
  
  void printGrid(grid pascal)
  {
      int i = 0;
      int j = 0;
      while (i &lt; size){
          while (j &lt; size){
              printf ("%3c", pascal[i][j]);
              j++;
          }
          i++;
      }
  }
  
  void drawGrid(grid pascal, int size)
  {
      createVoid(pascal, size);
      createNumbers(pascal, size);
      printGrid(pascal);
  }
  </code></pre>
  
  <p>functions.h</p>
  
  <pre><code>#ifndef FUNCTIONS_H
  #define FUNCTIONS_H
  #include "magic.h"
  
  int getSize(void);
  void drawGrid(grid pascal, int size);
  void createVoid(grid pascal, int size);
  void createNumbers(grid pascal, int size);
  void printGrid(grid pascal, int size);
  
  #endif // FUNCTIONS_H
  </code></pre>
  
  <p>magic.h</p>
  
  <pre><code>#ifndef MAGIC_H
  #define MAGIC_H
  #include &lt;stdlib.h&gt;
  
  #define VALUE_ZERO '0'
  
  typedef char grid[][];
  
  #endif // MAGIC_H
  </code></pre>