C语言——typedef
作者:互联网
1
#include<stdio.h>
typedef struct Student
{
int sid;
char name[100];
char sex;
}* PST; // PST 等价于 struct Student * 定义的变量为指针
int main()
{
struct Student st;
PST ps = &st;
ps->sid = 99;
printf("%d\n", ps->sid);
return 0;
}
2
#include<stdio.h>
typedef struct Student
{
int sid;
char name[100];
char sex;
}* PST, ST; // PST 等价于 struct Student * 定义的变量为指针, ST 等价于 struct Student 定义的变量为普通的结构体变量
int main()
{
ST st; // struct Student st;
PST ps = &st; // struct Student * ps = &st;
ps->sid = 99;
printf("%d\n", ps->sid);
return 0;
}
标签:ps,typedef,struct,C语言,Student,sid,st,PST 来源: https://blog.csdn.net/qq_36267036/article/details/115559205