title: Passing variable sized multi-dimensional array by pointer in C
body: <p>I am trying to pass a 2D array of variable size to a function to print it. I know how it's done when one has fixed sized arrays. But how does one do this with variable sized arrays? Here is some code that'll give you an idea what I am trying to do:</p>
  
  <pre><code>void print_grid(char (*g)[9], int size) // the array subscript (9 here) be variable
  {
     int i, j;
     for (i=0; i&lt;size; i++)
     {
        for (j=0; j&lt;size; j++)            
           printf("%c ", g[i][j]);
        printf("\n");
     }
  }
  </code></pre>
  
  <p>I'll call this function using the following code:</p>
  
  <pre><code>char a[3][3], b[9][9];
  // assign a, b
  print_grid(a, 3);
  print_grid(b, 9);
  </code></pre>
  
  <p>Is there any way to do this without allocating any dynamic memory in print_grid()?</p>