回调函数案例(一)
1 #include <stdio.h> 2 3 typedef void*(*FUN)(void *) ; 4 5 int test(FUN pfun, void *arg) 6 { 7 pfun(arg); 8 return 0; 9 } 10 11 void *fun(void *arg) 12 { 13 int val = (int) arg; 14 printf("val=%d\n", val); 15 return (void *)0; 16 } 17 18 int main() 19 { 20 test(fun, (void *)100); 21 return 0; 22 }
运行结果是
val=100