如果你typedef
的函数指针,这种调用更容易理解:
#include#include // addFuncPtr_t is a pointer to a function that: // - returns int // - takes two int arguments typedef int ( *addFuncPtr_t )( int, int ); int add(int x, int y) { return (x + y); } void passptr(addFuncPtr_t fp, int a, int b) { int result = fp(a, b); printf("%d", result); } int main() { add(3, 5); // note that the function is passed separately from // the arguments - add(3,5) would *call* the function // instead of passing the address of the function passptr( add, 3, 5 ); getch(); return 0; }