#include<stdio.h>
#include<stdlib.h>
void study(){
printf("好好学习,天天向上
");
}
//定义结构体
//结构体中不能定义函数,但是可以定义函数指针
struct student{
int age;
char sex;
void(*study)();
};
main(){
struct student st = {20,'f', study};
printf("%d
", st.age);
//printf("结构体长度为%d
", sizeof(st));
//访问结构体的函数指针
st.study();
struct student* stp = &st;
//引用结构体中的这个函数指针 ->左边必须是结构体的一级指针
stp->study();
}