#include <stdio.h> typedef void (*fun_cb)(int a, int b); static fun_cb exe_fun_cb; void fun_cb_input(int, int); void setUp_cb(fun_cb); void main() { setUp_cb(fun_cb_input); } void setUp_cb(fun_cb fun_cb_param) { printf("\n ready to use callback \n"); exe_fun_cb = fun_cb_param; if(exe_fun_cb) { exe_fun_cb(0, 0); } } void fun_cb_input(int param1, int param2) { printf("\n this is a callback function!\n"); }
运行结果:
时间: 2024-11-14 10:01:16