#include "stdio.h" 总的来说typedef作用是给某个类型起名字
int main()
{
/*一
typedef struct{
int a;
}stu;
stu s1; //stu==struct student ,这里只是省略了student,可有可无,可与三对比
s1.a=6;
printf("%d",s1.a);
*/二
struct student{
int a;
}stu;
struct student stu1; // 1和3其实差在student;没有什么差别;但如果没有student就不能有struct student stu1了;
stu1.a=6;
//stu.a=6; //上面两行不要,只要这一行也是可以的
printf("%d",stu1.a);
/*三
typedef struct student{
int a;
}stu; //stu==struct student
stu s1;
s1.a=6;
printf("%d",s1.a);
*/
}typedef struct解释
最新推荐文章于 2024-09-06 10:12:52 发布
本文探讨了C语言中typedef关键字的作用及其与结构体定义之间的关系。通过具体示例介绍了如何使用typedef简化结构体类型的声明,并展示了不同方式下结构体成员的访问方法。
1159

被折叠的 条评论
为什么被折叠?



