Review what integer array, an array of characters, an integer pointer arrays, array of character pointers, integer array pointer, a character array pointer
20:52:01 2019-12-31
Integer array int a [10];
character array char b [10];
_______________________
pointer to an integer array int * p [10]; | __ | __ | __ | __ | __ | __ | __ | __ | __ | house of each cell is stored a pointer, each pointer is of type int, It will point to the value of an int.
. 1 for ( int I = 0 ; I < 10 ; I ++ ) 2 p [I] = & a [I]; // . The address of a each element of the array of pointers are placed in p . 3 . 4 for ( int = J 0 ; J < 10 ; J ++ ) . 5 the printf ( " % D " , * (p [I])); // the p into real addresses in content, i.e. using the * address values.
Character pointer array char * c [10]; and above, each pointer is of type char, char points to a
Is the following two equations. Showing both sides of the left and right values are equal
a == &a[0]
*a[i] == a
Focus here array pointer
Integer array pointer int (* P) [10] ; p is a pointer that points to an array of the grid 10 of the grid 10 are stored int type of thing.
int a[10]; int (*p)[10]; p = a; p = &a;
. 1 #include <stdio.h> 2 #include <stdlib.h> . 3 . 4 int main () { . 5 . 6 int A [ 10 ] = { . 1 , 2 , . 3 , . 4 , . 5 , . 6 , . 7 , . 8 , . 9 , 10 }; 7 int (the p-*) [ 10 ]; 8 the p-& a =; // the wording is correct and error- 9 // the p-= a; such an approach would warn though we know the name of the array. may be used as the first address of the array. 10 int I =0 ; . 11 for (I = 0 ; I < 10 ; I ++ ) 12 is the printf ( " % D " , p [ 0 ] [I]); // where p points to the first address is actually a two-dimensional array, but the actual is a point on an array, so p [0] [0] is the array a a [0] a. 13 is // P where [0] [i] is the first line through the array. 14 / * 15 the above p = & a; fact, this statement is to p [0] points to a [10] Therefore, p [0] [i] needs only i ++ to operate a [i] a. 16 p [0] -> [p00] [p01] [p02] [p03] [p04] [p05] [p06] [p07] [p08] [p09] line. 1 . 17 P [. 1] -> [P10] [...] [...] [...] [...] [...] [...] [...] [...] [...] 2, line 18 p [2] -> [p20 ] [...] [...] [...] [...] [...] [...] [...] [...] [ ...] line. 3 . 19 P [. 3] -> [P30] [...] [...] [...] [...] [...] [...] [.. .] [...] [...] line. 4 20 is P [. 4] -> [P40] [...] [...] [...] [...] [...] [...] [...] [...] [...] line. 5 21 is P [. 5] -> [P50] [...] [...] [...] [. ..] [...] [...] [...] [...] [...] line. 6 22 is P [. 6] -> [P60] [...] [... ] [...] [...] [...] [...] [...] [...] [...] line. 7 23 is P [. 7] -> [P70] [ ...] [...] [...] [...] [...] [...] [...] [...] [...] line. 8 24 P [ 8] -> [p80] [ ...] [...] [...] [...] [...] [...] [...] [...] [.. .] line. 9 25 P [. 9] -> [P90] [...] [...] [...] [...] [...] [...] [...] [...] [p99] line 10 26 after the above table, we can know how the array pointer p is a pointer to a. array pointer turned out to be a two-dimensional pointer p. 27 * / 28 29 return 0; 30 }
Character array pointer char (* c) [5] ;
this sentence only c this symbol of our own writing, other symbols C compiler know.
So let's c what goods products should be how to read.
C is a pointer that points to a length of 5 which kept the character array
According to such a read method, the int (* p) [10] ; also good read
p is a pointer that points to a length of an integer number of memory inside the array 10