回调函数是使用函数指针实现的
#include
#include
typedef void (*Fun_t)(void);
void test(Fun_t fun, unsigned int t);
void handle()
{
printf("Hello!\n");
}
int main( )
{
test(handle, 5);
return 0;
}
void test(Fun_t fun, unsigned int t)
{
while (t--)
{
Sleep(1000);
}
fun();
}
这写的还不错,你参考一下吧
https://baike.baidu.com/item/回调函数/7545973?fr=aladdin
有这种叫法吗?是不是递归调用?