First, the standard method:
Analysis: Function pointer array is an array whose elements are function pointers. In other words, this data structure is an array, and its elements are pointers to the address of the function entry. ?
According to analysis: first of all, it is an array: array name []?
Secondly, you need to explain the data type pointer of its elements: * array name []. ?
Third, make it clear that each array element is a pointer to the function entry address: function return value type (* array name []) (). Please note why "* array name []" is expanded in brackets here. Because parentheses and array descriptors have the same priority, what does * array name [] () mean according to the combination direction of parentheses and square brackets if you don't use parentheses to extend the pointer array to describe the expression? Is an array of functions whose element return value type is pointer. Is there such a function ancestor? I don't know, so I have to enclose it to make sure that every element of the array is a pointer.
Second, the deception method:
Although this function is not a variable, it still has its physical address in memory, which can be assigned to the pointer variable. The way to get a function is to use the function name without parentheses and parameters.
The function name is equivalent to the const pointer pointing to its function entry. So since the function name is a pointer constant, you can do some corresponding processing, such as forced type conversion. ?
Then we can put this address in an array of integer pointers and call it as a function pointer.
(1) Call a function with a function pointer variable.
You can use pointer variables to point to integer variables, strings, arrays, structures, or functions. A function is assigned an entry address at compile time. This entry address is called a function pointer. You can point to a function with a pointer variable, and then call this function through the pointer variable. Take a simple numerical comparison as an example:
1 # include & lt; stdio.h & gt
2 # contains & ltstdlib.h & gt
3?
4 ? int main()
5 {
6 int max(int,int);
7 int (*p)(int,int);
8 int a,b,c;
9 p = maximum;
10 scanf("%d, %d ",& i, & b);
1 1 c = (*p)(a,b);
12 printf("a=%d,b=%d,max=%d\n ",a,b,c);
13 returns 0;
14 }
15?
16 int max(int x,int y)
17 {
18 int z;
19 if(x & gt; y)z = x;
20 else z = y;
2 1 return (z);
22 }