Definition format, and methods
Function pointers are declared by: Return value type (* pointer variable name) ([Formal parameter list]); Note 1: “Return value type” indicates the return type of the function. The parentheses in “(pointer variable name)” cannot be omitted. The parentheses change the priority of the operator. If the parentheses omitted as a whole, it becomes a function description, indicating that a data type returned is a function of a pointer, and the latter “parameter list” indicates the parameters of the function pointed by the pointer variable.square steel tubing
Int func (int x); /* Declares a function */
Int (* f) (int x); /* declares a function pointer */
f = func; /* assigns the first address of the func function to the pointer f */
Type name * function name (function parameter list); Among the function, the suffix operator parentheses “()” denotes that this is a function, and its prefix operator asterisk “*” denotes that this function is a pointer function which function value is a pointer, that is, the type of value it brings back is a pointer. When this function is called, a “pointer return value” will be obtained as the address, “type name” indicates the type to which the pointer returned by the function points.
Int * pfun (int, int); Since the priority of asterisk “*” is lower than that of parentheses “()”, the combination of pfun with the later “()” means that pfun is a function.
That is: int* (pfun (int, int)); Then it combines with the previous “*” to show that the return value of this function is a pointer. Because there is an int ahead, that is to say, pfun is a function that returns an integer pointer.