在C语言里,struct用于定义一个数据类型------结构体,typedef用于给数据类型取别名。
typedef struct Student{ int Age; int Id[10];}Stu;表示给结构体变量struct Student取了一个别名Stu。这样下次定义一个结构体变量就可以写成Stu stu1。如果不用typedef。
struct Student{ int Age; int Id[10];}Stu;此时说明已经定义了一个结构体变量Stu,如果要重新定义一个结构体变量,要写成struct Student stu1。
结构体指针
这样就可以用BstNode p来定义指针p;如果不用typedef。
struct BiNode{ int data; struct BiNode *lchild,*rchild;}BiTree,*BstNode;表示已经定义了一个结构体指针BstNode,如果要重新定义一个结构体指针,要写成struct BiNode *BstNode1。