Understanding of Pointer Knowledge

array of pointers

An array of pointers is an array, an array of pointers (addresses)  

int *arr1[10]; The pointer of type int* is placed in the array arr1

char *arr2[4]; The pointer of type char* is placed in the array arr2

char **arr3[5]; The pointer of type char** is placed in the array arr3

array pointer

An array pointer is a pointer to an array of deterministic size and type

int (*p)[10] p is first combined with *, indicating that p is a pointer variable, which is a pointer to an array with a size of 10 integers

Note: 1. Int (*p)[10] cannot be changed to int (*p)[9] Reason: The type of space is different, and its type is definitely different 

       2. The dimension of the two-dimensional array is reduced to a pointer to its internal element type, and the array pointer can be used when passing parameters

Note: When judging what type of data is, it mainly depends on the type of the data with the highest priority of the most recent symbol of the variable name.

function pointer

A function pointer is a pointer variable that stores the address of the function

Note: The entry address of the function is function name or & function name

void *pfun2( ); function declaration

void (*pfun1)( ); function pointer

int(*p[5])( ); array of function pointers

int(*(*p)[5])( ); pointer to an array of function pointers

int(*(*p[4])[5])( ); array of function pointer array pointers

(*(void(*)( ))0)( ); function call <cast type to function pointer type dereference as function name and add () to function call>

void(*signal(int,void(*)(int)))(int); function declaration

array of function pointers

Store the address of a function in an array, which is called an array of function pointers

int (*parr1[10])( ); array of function pointers                        

                                  Explanation: parr1 is first combined with [ ], so it is an array, and the content in the array is a function pointer of type int(*)( ).

pointer to array of function pointers

A pointer to an array of function pointers is a pointer; a pointer points to an array, and the elements of the array are all function pointers

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325171011&siteId=291194637