Let's look at pointers in C + +, which is just an extension
Array pointers
In fact, the main point here is the pointer operation in C + +
/* Array element pointer: A variable has an address, an array contains several elements, each array element has a corresponding address, and a pointer variable can point to an array element (the address of an element is placed in a pointer variable) A pointer to an array element is an array element whose address can be pointed to an array element int a[10]={1,2,3,4,5,6,7,3,2,3} with a pointer variable; int *p; p=&a[0]; Equivalence and p=a; equivalent to int *p=a; Equivalence with int*p=&a[0] Note: 1) The array name A does not represent the entire array, only the address of the first element of the array p=a is "Assigning the address of the first element of a array to the pointer variable P" instead of "assigning the value of each element of the array A to P" array Pointers: pointer array pointers to array elements: using an array pointer to indirectly access the array pointer's definition of an element array: int *p; array pointer initialization; int a[4] ={1,2,3,4}; int *p = a;//array pointer, defines the first address of a pointer variable p assignment array (the address of the first element), p points to the first element of the array int *p = &a[0];//equivalent to the above sentence array pointer How to access the elements of the array: 1) p+1 represents the next element to the array 2) p-1 points to the previous element of the array error: Iterating the array for (int i=0;i<4; i++) { printf ( "%d\t", *p++); } The misunderstanding of Learning: array name A is a constant equivalent to * (10++) //array name + + This is the wrong printf ("*a=%d\n", *a++);//The notation is wrong */
Pointers in the C language