//typedef的用法
#include
typedef struct Student
{
int sid;
}ST;
int main(void)
{
struct Student st; //等价于ST st;
st.sid = 29;
printf("%d n", st.sid);//29
//struct Student pst = &st; //等价于STpst=&st;
ST st2;
st2.sid = 20;
printf("%d n", st2.sid);//20
return 0;
}
用法二:
#include
typedef struct Student
{
int sid;
}*PST;//等价于struct Student *类型
int main(void)
{
struct Student st;
PST ps = &st;
ps->sid = 20;
printf("%d n", st.sid);
return 0;
}
用法三:
#include
typedef struct Student
{
int sid;
}PST,ST;//等价于ST代表了struct Student,PST代表了struct Student
int main(void)
{
ST st; //等价于struct Student st;
PST ps = &st; //等价于struct Student *ps=&st;
ps->sid = 20;
printf("%d n", ps->sid);
printf("%d n", st.sid);
printf("%d n",(*ps).sid);
return 0;
}



