***********************无参回调函数*************************
void callback_fun()
{printf("this call back function have not arguments.\n");
}
void call(void (*fp)())
{
//两种调用方式
fp();
//(*fp)();
}
int main()
{
call(callback_fun);
}
==================================
输出结果:
this call back function have not arguments.
***********************带参数的回调函数*************************
void callback_fun(int arg)
{printf("the call back function arg is:%d\n", arg);
}
void call(void (*fp)(int), int arg)
{
(*fp)(arg);
}
int main()
{
call(callback_fun, 8);
}
==================================
输出结果:
the call back function arg is:8