- 函数指针
- void(*p)(int),返回值是void,参数是int
- void(*B(int x,void(*h)(int)))(int); B的返回值也是函数指针,参数是int 和函数指针
- #include <stdio.h>
#include <stdlib.h>
//第一个函数指针
void (*P)(int);
//测试函数
void p1(int);
//第二个函数指针
void(*B(int x,void(*h)(int)))(int);
//简化
typedef void(*T)(int);
T T1(int x,T t);
int main(void) {
//P=p1;
//P(1);
//第二个函数指针
P=B(10,p1);
P(11111);
//简化后的
P=T1(100,p1);
P(22222);
return EXIT_SUCCESS;
}
void p1(int x){
printf("测试值:%d\n",x);
}
void(*B(int x,void(*h)(int)))(int){
h(x);
return h;
}
T T1(int x,T t){
t(x);
return t;
}