1. Arrays and pointers
int array[5] = {1,2,3,4,5}; // Defining Arrays
1. Pointer and array relationships
int * pa = array;
pa = array; // p[0] = = * (p+0) = = Array[0] = = * (array+0) printf ("%p\n", PA); printf ("%p\n", array); /* Access An array of two ways 1. The subscript method accesses the array name [subscript] pointer [subscript] subscript: Offset 2. Pointer method Access * (p+1) */
2. Array of pointers
int array[5 ] = {1 , 2 , 3 , 4 , 5 }; // defines an array int (*p) [5 ] = &array; // Defines an array pointer int *arr[5 ]; // pointer array, so the element in the array retains the position of the int pointer
*p = p[0]; (*p) [1] = = array[1]; p[0] [1] = = (*p) [1] = = array[1];
3. Two-D array pointers
//pointers to 32-D arrays intarray2[2][3] = {{1,2,3},{4,5,6}}; int(*P2) [2][3] =NULL; P2 = &array2;//assigns the array pointer to the array*p = =array2; (*P) [0][0] = = p[0][0][0]; // /** //p + 1 crosses 6 * 4 bytes//P[0] + 1 crosses 3 * 4 bytes//P[0][0] + 1 crosses 4 bytes//P[0][0][0] + 12-d array first element value +1// */
4. Array of pointers
The elements in the array are pointers (addresses)
int *arr[5]; // array of pointers, so the elements in the array retain the position of the int pointer int 1 ; arr[1] = &a;
5. Pointer to pointers
// 4. Two-D pointer int A; int *p = &A; int **pp = Pointer to &p;//pointer
C language arrays, pointer arrays, array pointers, two-dimensional array pointers