Most beginners are not very clear about the existence of a two-dimensional array, today I would like to say that the two-dimensional array, computer memory is a series of storage units, we can interpret it as a line, yes, it is a line, then the problem, the two-dimensional is a what kind of existence??? Frankly speaking, the two-dimensional array is not really two-dimensional, but people are subjective to turn it into two-dimensional, for example! such as stairs, we all know that the staircase is a way to say plainly, but we deliberately move the staircase up and down the way, this is our subjective change, in fact we can be seen as a straight road, but the workers are bent. Okay, no, come on, go to the subject ....
The two-dimensional array name A is a pointer to the first row of the array, it points to an entire line, *a is the address of a[0][0], the array name A is an entire line address, *a is an element of the address, but at this time p=a, this p is a[0][0] address see the following program
1#include <stdio.h>2 3 intMain ()4 {5 inta[2][3]={1,2,3,4,5,6},*p;6 7p=A;8 9printf"%d%d%d\n", p,a,*a);Ten One return 0; A}
Results show
The address of the first line and the first element first address must be the same, we continue to see
1#include <stdio.h>2 3 intMain ()4 {5 inta[2][3]={1,2,3,4,5,6},*p;6 7p=A;8 9printf"%d%d\n", (p+1), * (A +1));Ten One return 0; A}
The results show that the address differences come out, the address of the No. 0 line is 6487600, so a[0][1] is 6487600, and the first row of the address is 6487612, is not a difference of 3 int byte, so this proves that a is the first line of the array of pointers, it points to a whole line, P is pointing to an element
Continue to prove
1#include <stdio.h>2 3 intMain ()4 {5 inta[2][3]={1,2,3,4,5,6},*p;6 7p=A;8 9printf"%d%d\n", * (p+1), * * (A +1));Ten One return 0; A}
Results
Conclusion: **a represents the address of the A[0][0],*a A[0][0], a represents the address of the first row
The relationship between the array name and its pointer in a two-dimensional array