title: Two dimension arrays and pointer representation
body: <p>Three questions in 1. </p>
  
  <ol>
  <li><p>If I have a 2-D array - </p>
  
  <pre><code>int array_name[num_rows][num_columns] 
  </code></pre>
  
  <p>So it consists of num_rows arrays -each of which is an array of size = num_columns. Its equivalent representation using an array of pointers is- </p>
  
  <pre><code>int* array_name[num_rows] 
  </code></pre>
  
  <p>-so the index given by [num_rows] still shows the number of 1-D arrays - somewhere using  malloc we can then specify the size of each of the 1-D arrays as num_columns. Is that right? I saw some texts telling </p>
  
  <pre><code>int* array_name[num_columns] 
  </code></pre>
  
  <p>will the indices not get switched in this case ?</p></li>
  <li><p>For a ID array I specify size dynamically as- </p>
  
  <pre><code>int *p;
  p = (int*) malloc (size * sizeof(int))
  </code></pre>
  
  <p>For 2 D arrays do I specify the size of entire 2-D array or of one 1-D array in malloc - </p>
  
  <pre><code>int*p [row_count];
  p = (int*) malloc (row_count * column_count * sizeof(int))
  </code></pre>
  
  <p>or</p>
  
  <pre><code>p = (int*) malloc (column_count * sizeof(int))
  </code></pre>
  
  <p>I think it should be the second since p is a pointer to a 1-D array and p+1 is a pointer to a 1-D array etc. Please clarify.</p></li>
  <li><p>For ques 2 - what if p was defined as -
  <code>int **p;</code> rather than 
  <code>int * p[row_count]</code> 
  How will the malloc be used then? I think it should be - </p>
  
  <pre><code>p = (int*) malloc (row_count * column_count * sizeof(int))
  </code></pre></li>
  </ol>
  
  <p>Please correct, confirm, improve.</p>