00-typedef----叫type re-name更恰当。给一个已经存在的数据类型(不是变量)取一个别名

 来自《C语言深度剖解》陈正冲老师编著(这本好书,解开了很多似懂非懂其实不懂假装懂得问题)

 1.结构体定义

typedef struct student{
    //code;
}Stu_st, *Stu_pst;

2.两种类型的等价 

struct student stu1;
Stu_st stu1;

两者等价

struct student *stu2;
Stu_pst stu2;
Stu_st *stu2;

三者定义等价。

3.解释:

看作整体:

struct student{
    //code
}

typedef 就是给上面取了别名叫“Stu_st”;

同时给

struct student{
    //code
}*

取了别名叫Stu_pst;

只是两者同时取而已

4.扩展

const Stu_pst stu3;
Stu_pst const stu4;

猜你喜欢

转载自blog.csdn.net/qq_39883358/article/details/84654365
今日推荐