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;
}
上一篇:神秘题目4


下一篇:PST转换软件 v6.3