Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Can you define a function pointer and its function body at the same time, that is, define a function pointer to point to a function body?
Can you define a function pointer and its function body at the same time, that is, define a function pointer to point to a function body?
You can define a function pointer to a function of the same type. The following small program is a simple example.

# include & ltstdio.h & gt

int Add(int a,int b)

{

Return (a+b);

}

Invalid master (invalid)

{

int(* p)(); //Define the function pointer

int a=4,b = 3;

P = add; //Point to the Add function, and pay attention to the unification of the return value.

printf("a+b=%d\n ",p(a,b)); //Call with function pointer

}