Arrays and pointers:
One:
Since the pointer can point to a variable, it must point to an array. This section explores the relationship between arrays and pointers. First, the reader must understand that the array name represents the address of the first element in the array.
So how do you represent the address of other elements in the array and the other elements themselves?
P+i or A+i is the address of a[i];
* (P+i) or * (A+i) represents the a[i] element.
It has been mentioned that the array name represents the first element address of the array, so all functions that use the array name as arguments can be rewritten
into a function that uses pointers to make arguments.
Two: the case of a multidimensional array.
here, the reader first has a sense that each dimension of a multidimensional array is also a one-dimensional array. Suppose there is a two- dimensional array a[3][4], then a[0],a[1],a[2] is a one-dimensional array (they are the array name and the address). So you can take a more abstract look at some of the presentation methods.
A two-dimensional array name, pointing to a one-dimensional array a[0],0 header address
A+1, &a[1] line first address
* (a+1), a[1] row 0 Column element address
* (a+1) +2,a[1]+2 row two column element address
* (* (* (a+1) +2), * (a[1]+2) The value of a row of two column elements
The above-mentioned representations must be noted, especially: A+1 represents the first line of the address, * (a+1) indicates
A row of 0 column element addresses, although their values are the same, but they are different, a+1+1 represents the two header addresses, and * (A+1) +1 represents the address of a row of elements.
Seriously understand the following two programs.
The relationship between two-dimensional arrays and pointers this is a lot of things are very abstract, and many things are anti-human intuition, bloggers understand also some difficulty, you have any method also welcome feedback.
C language Pointer tutorial----Getting started to master < two >