C语言带参数回调函数测试
一、概述
案例:写一个小案例来测试C的带参数的回调函数
二、代码实例
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/**
* 回调函数定义
*
* */
int callback(int x,int y){
printf("my littler baby is luoluoyang:%d,%d",x,y);
return 0;
}
/**
* 回调函数使用
* 结构:返回值 (函数名指针) (函数参数)
* */
int handler(int x,int y,int (*callbackFun)(int,int)){
callbackFun(x,y);
return 0;
}
/**
* 测试
* */
int main(int argc, char const *argv[])
{
handler(10,20,callback);
return 0;
}
浙公网安备 33010602011771号