首页 > 编程语言 > 详细

C语言回调函数

时间:2021-04-12 22:23:33      阅读:28      评论:0      收藏:0      [点我收藏+]

#include <stdlib.h>
#include <stdio.h>
int Callback_1(int a) ///< 回调函数1
{
printf("Hello, this is Callback_1: a = %d \n", a);
return 0;
}

int Callback_2(int b) ///< 回调函数2
{
printf("Hello, this is Callback_2: b = %d \n", b);
return 0;
}

int Callback_3(int c) ///< 回调函数3
{
printf("Hello, this is Callback_3: c = %d \n", c);
return 0;
}

int Handle(int x, int (*Callback)(int)) ///< 注意这里用到的函数指针定义
{
Callback(x);
return 0;
}

int main()
{
Handle(4, Callback_1);
Handle(5, Callback_2);
Handle(6, Callback_3);
return 0;
}

待完善

C语言回调函数

原文:https://www.cnblogs.com/txzing/p/14649734.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!