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;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章