c语言回调函数
原创
©著作权归作者所有:来自51CTO博客作者liuxiwu123的原创作品,请联系作者获取转载授权,否则将追究法律责任
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int *swap(int *,int *);
typedef int* (*callback)(int *,int *);
int * func(callback,void *,void *);
int main(int argc, char const *argv[])
{
int c=4,d=5;
printf("input your number:\n\r");
scanf("%d,%d",&c,&d);
printf("c=%d,d=%d\n",c,d );
int *p =func(&swap,&c,&d);
printf("c=%d,d=%d\n",c,d );
}
int *swap(int *a,int *b){
int temp = *a;
*a=*b;
*b =temp;
return a;
}
int * func(callback call,void *a,void*b){
printf("execute callback function result:\n");
return call((int *)a,(int *)b);
}
下一篇:c语言算法--汉诺塔
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java实现异步回调返回给前端
java实现异步回调返回给前端
Java Async 数据 -
C语言--回调函数
什么是回调函数? 简而言之,回调函数就是一个通过函数指针调用的函数。如果你把函数的指针(地址)作为参数传递给
C 指针 回调函数 C++ 参数