为结构体中函数指针赋值的两种方法
2013-08-16 12:00
176 查看
/** * 为结构体中的指针数组赋值 */ #include <stdio.h> typedef struct test { void (*p)(void); void (*q)(void); void (*y)(void); }test; void f1(void) { printf("f1\n"); } void f2(void) { printf("f2\n"); } void f3(void) { printf("f3\n"); } int main(void) { test aa = { p : f1, //方法1 .q = f2, //方法2, 一般这种方式在全局变量初始化的时候常用 }; aa.y = f3; //方法3 aa.p(); aa.q(); aa.y(); return 0; }
相关文章推荐
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 为结构体中函数指针赋值的两种方法
- 函数指针在结构体中的赋值方法
- java中关于给属性赋值的两种方法
- C语言学习——一种新的结构体赋值方法
- edit框添加与赋值的两种方法