1: Array of pointers: the elements inside this array are all pointers ;
Such as:
int a[] = {1,2,3,4,5};
int *p[] = {&a[0],&a[1],&a[2],&a[3],&a[4]};//All elements are addresses
2: Array Pointers:
A pointer to an array is called an array pointer
int (*p) [4]; The array pointer is the row pointer; The P pointer points to an array of 4 values of type int
3: Function pointer:
A pointer to a function
The return type is the return type of the int function; parameter is the parameter type of the function fun
Int (*fun) (int x, int y);
Such as:
/* p is a function pointer */
Assignment value:
Int (* p) (int, int) = & Max; & can omit Max as a function
Use:
P (A, B);//equals Max (b)
4: pointer function:
The pointer function returns an address;
int * Fun (int x)
{
int *p = &x;
return p;
}
5: Use of function pointer arrays
/* Define function pointer array variable Fun_array
(int,int) a list of functions corresponding to the function pointer array that points to 4 function names
*/
Int (*fun_array[4]) (int,int) = {Add, sub, mul, Div};
int result = Fun_array[0] (i,j); A function that represents the No. 0 array element is called the Add function
The difference between pointer arrays and arrays of pointers