标签:size std char s main highlight blog 学习 oid 访问
#include<stdio.h>
#include<stdlib.h>
void study(){
printf("好好学习,天天向上 \n");
}
//定义结构体
//结构体中不能定义函数,但是可以定义函数指针
struct student{
int age;
char sex;
void(*study)();
};
main(){
struct student st = {20,‘f‘, study};
printf("%d\n", st.age);
//printf("结构体长度为%d\n", sizeof(st));
//访问结构体的函数指针
st.study();
struct student* stp = &st;
//引用结构体中的这个函数指针 ->左边必须是结构体的一级指针
stp->study();
}
标签:size std char s main highlight blog 学习 oid 访问
原文地址:http://www.cnblogs.com/loaderman/p/6415535.html