Daily pointer to a function in CEvery day, I picked up a C-language shell, which grew up and formed thousands of miles.
Today's shells: What about pointer pointing to a function?In C language, a function itself is not a variable, but can define a pointer to a function. Such pointers are called function pointers, which can be assigned values and function parameters.1.Define function pointer: The definition of the function pointer must be consistent with that of the pointing function. This consistency is reflected in two aspects:1.1 consistent return values1.2 consistent ParametersFor example: function:IntFoo(IntA,IntB)The pointer to the function:Int(* P )(Int,Int)The function pointer returns the value. The parameter list must be the same as that of the function. (* p) brackets must exist.2. function pointer assignment:The value assignment statement: p = foo; can realize the function pointer pointing to the foo () function. The function is similar to the array:1. The value assignment does not require the Access & operator.2. Use indirect operators not required *.3. General Usage of function pointers:In the next section, we will explain a clever use of function pointers.