一、概述

  案例:写一个小案例来测试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;
}

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-16
  • 2021-11-30
  • 2021-10-19
  • 2021-07-11
  • 2021-11-02
猜你喜欢
  • 2022-12-23
  • 2021-11-20
  • 2021-06-30
相关资源
相似解决方案