//typedef的用法
#include <stdio.h>
//为int再重新多取一个名字,ZHANGSAN等价于int
//为已有的数据类型写名字
typedef int ZHANGSAN;
struct Strudent
{
int sid;
char name[100];
char sex;
}ST;
//即可以用ST又可以用struct Student
int main(int argc, char *argv[])
{
struct Student st;//等价于ST st;
struct Student * ps = &st;//等价于ST*ps;
return 0;
}
//如何理解
struct Strudent
{
int sid;
char name[100];
char sex;
}*PST;//PST等价于struct Student *
int main(void)
{
PST ps =&st;
ps->sid = 99;
return 0;
}
typedef struct Student
{
int sid;
char name[100];
char sex;
}*PSTU,STU;
//等价于STU代表了struct Student,PSTU代表了struct Student *
int main(void)
{
STU st;
PSTU ps = &st;
pa->sid = 99;
}
typedef的用法
最新推荐文章于 2024-05-09 17:24:06 发布