title: Memory map for a 2D array in C
body: <p>Do you think what <a href="http://www.mattababy.org/~belmonte/Teaching/CCC/CrashCourseC.html" rel="noreferrer">this discussion</a> about memory-map of 2D array is correct? <a href="http://www.mattababy.org/~belmonte/Teaching/CCC/CCC/transparent_figure5.gif" rel="noreferrer">Especially this photo?</a> Can you explain the theory?</p>
  
  <p>Suppose we declare a 2D array in C like this:</p>
  
  <pre><code>int arr[3][3]={10, 20, 30, 40, 50, 60, 70, 80, 90};
  </code></pre>
  
  <p>Now, according to this discussion, the memory would be arranged like the following:</p>
  
  <p><img src="https://i.stack.imgur.com/7uiSD.jpg" alt="enter image description here"></p>
  
  <p>Now, I have written the following code to test this theory:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  main()
  {
      int arr[3][3]={10, 20, 30, 40, 50, 60, 70, 80, 90};
      printf("      arr==%d\n", arr);
      printf("  &amp;arr[0]==%d\n", &amp;arr[0]);
      printf("   arr[0]==%d\n", arr[0]);
      printf("&amp;arr[0][0]=%d\n", &amp;arr[0][0]);
      printf(" arr[0][0]=%d\n", arr[0][0]);
  }
  /*
  Output:
  ========
        arr ==1245028
    &amp;arr[0] ==1245028
     arr[0] ==1245028
  &amp;arr[0][0]==1245028
   arr[0][0]==10
  Press any key to continue...
  */
  </code></pre>
  
  <p>Why the first 4 outputs are same?</p>