1. pointer type to function
Define the pointer type to the function:
// The Void type indicates any type
Typedef void (* FP) (void); // defines the pointer type of the function that points to the returned void type. You need to input a void type parameter.
FP; // define the variable fp
Fp = math. sin; // assign the variable FP to the sin function.
// The method for calling the function pointer is as follows:
Void main ()
{
FP ();
(* FP )();
}
// A good example of using function pointers is: Message ing table
2. Call back)
Local service functions or callback functions are often used when different modules call each other. Pointers to functions are often used.
Service (void (* FP) (void ),......)
The above function uses a pointer to the function, used to call when the external module completes the work.
When you call a function from another place, you know that the interface of the local module is service (). In this function, you can input a function from another place. When the service is completed locally, this function will be called from other places, which is equivalent to notifying a program from another place.