#include<stdio.h>
typedef struct Student
{
int age;
int score;
}St;
int main()
{
St st={200,100};//等价于 struct Student st 直接命名,省略/很多不必要步骤
printf("%d",st.age);
}
typedef的核心在于指针而不是仅仅简化了结构
#include<stdio.h>
typedef struct Student
{
int score;
int age;
}ST,*PST;//相当于直接给了个*号 struct Student *
int main()
{
ST st={100,20};
printf("%d\t",st.age);
PST pst=&st;
pst->age=25;
printf("%d",st.age);
}
PST相当于struct Student *
可以直接命名指针,下次代码中就不需要指针了。