Pointer array, array pointer, function pointer:
1. pointer array: the data items of the array are pointers. The most common is the string pointer array. See the following example:
Char * cities = {"Jinan", "Qingdao", "biejing", "Shanghai", "Wulumuqi "};
Note the initialization method of pointer array: Put the five string constants in the Data zone, and cities only store these five pointers.
Comparison with 2D data:
Char cities2 [] [9] = {"Jinan", "Qingdao", "biejing", "Shanghai", "Wulumuqi "};
This looks very similar to the pointer array. The occupied space is quite different: the pointer array contains actual space, and each string in the two-dimensional array occupies nine characters.
2. array pointer: pointer to an array. This can distinguish between function pointers and pointer arrays. For example:
INT (* pint) [5]; // array pointer
INT (* pfunc) (INT); // function pointer ----------- is similar in shape? Is the name very similar?
Array pointer type (data type): int (*) [5], the following code will give an error prompt:
Int A [5] = {1, 2, 3, 4, 5 };
Pint = A; // error message: Type incompatible int (*) [5] to int *
Pint = & A; // correct, reflecting the concept of pointing;
Generally, array pointers and two-dimensional arrays are used together:
Int AA [3] [5] = };
Pint = AA;
3. function pointer: pointer to a function.
Its Type: int (* pfunc) (INT); ---> int (*) (INT)
Function pointers are mainly used as the address for passing function parameters. But it can also be used as the return value.
Parameter: int signal (INT Sig, void (* func) (INT ))
Return Value: void (* signal2 (INT). signal2 parameter is int, return value is void (*) (INT)