Pointer to a 2D dynamic Array Pointer
<p>How to create a pointer to the following 2D array pointer int **arr. I am looking for something similar to int*** arr and its allocation, deallocation, accessing and usage.</p>

<pre><code>int main()
{
  int** arr;

  int row = 11;
  int col = 2;
  int i,j;

  arr = (int**)malloc(sizeof(int*)*row);
  for (i=0; i&lt;row; ++i){
    arr[i] = (int*)malloc(sizeof(int)*col);
  }

  for (i = 0; i &lt; row; i++) {
    for (j = 0; j &lt; col; j++) {
        arr[i][j] = i;
        printf("arr[%d][%d] : %d\n",i,j,arr[i][j]);
    }
  }

  return 0;
}
</code></pre>

<p><strong>Previous references:</strong></p>

<p>Dynamic 2D array Pointer:</p>

<p><a href="https://stackoverflow.com/questions/11463455/c-programming-initialize-2d-array-dynamically">C programming initialize 2D array dynamically</a></p>

<p>Pointer to dynamic 2D array, But the explanation here is using <em>new</em> keyword and I want to use <em>malloc</em> instead: </p>

<p><a href="https://stackoverflow.com/questions/1768294/how-to-allocate-a-2d-array-of-pointers-in-c">How to allocate a 2D array of pointers in C++</a></p>

<p><strong>Additional Info:</strong></p>

<p>Consider following scenario: </p>

<p><code>XYZ* arr[A][B];</code></p>

<p>"XYZ" is a custom datatype, 
"A" &amp; "B" are dynamic variables at runtime</p>

<p>In this case, how can we define A &amp; B at runtime and access <code>arr[A][B]</code> element values using <code>XYZ*</code> type.</p>