我只写了个简单的demo程序,具体的使用方法,我就不再说了!
-
#include <stdio.h>
-
-
typedef int (*addr2_func_t)(int a, int b);
-
typedef int (*addr3_func_t)(int a, int b, int c);
-
-
int addr2(int a, int b)
-
{
-
return (a + b);
-
}
-
-
int addr3(int a, int b, int c)
-
{
-
return (a + b + c);
-
}
-
-
-
int fun1(addr2_func_t addr2_, addr3_func_t addr3_)
-
{
-
int ret_val = -1;
-
int a = 1;
-
int b = 2;
-
int c = 3;
-
-
ret_val = addr2_(a, b);
-
printf("addr2(a, b):%d\n", ret_val);
-
-
ret_val = addr3_(a, b, c);
-
printf("addr3_func_t(a, b, c):%d\n", ret_val);
-
-
return ret_val;
-
}
-
-
-
/**/
-
int main(int argc, char **argv)
-
{
-
fun1(addr2, addr3);
-
return 0;
-
}
阅读(1230) | 评论(0) | 转发(0) |