c语言中的回调函数

来源:互联网 发布:知而不争 不可谓忠翻译 编辑:程序博客网 时间:2024/05/16 02:09

先来一段代码

#include<stdio.h>

void show(void(*ptr)()){
 (* ptr)();  
}
void show1(){
printf("hello world");
}
void show2(){
printf("ni hao");
}
int main(){
show(show1);
printf("\n");
show(show2);
return 0;

}

回调函数,就是要操作系统来调用函数,这叫做回调


结果如图所示,细细体会