C语言带参回调函数使用简单样例:
#include <stdio.h>
void test1(int a,int b)
{
printf("test1:%d\n",a+b);
}
void test2(char* c)
{
printf("test2:[%s]\n",c);
}
void test3(int a,int b,void (*callback1)(int ,int),void (*callback2)(char *))
{
char buff[20] = "abcdefghigklmn";
callback1(a,b);
callback2(buff);
}
int main(void)
{
test3(5,10,test1,test2);
return 0;
}
运行结果: