typedef struct:只是定义了一个新的类型名称,这个类型名称可以用来定义结构体变量,但是其本身并没有定义任何结构体变量
typedef struct node:定义了一个新的类型名称,同时将这个新类型名称指向一个结构体变量
因此,当我们使用typedef struct node来定义结构体变量时,可以直接使用node作为结构体变量的类型名称。
对于代码的区别在于
struct student{
int a;
}
//声明时必须用struct student stu1
typedef struct student{
int a;
}stu;
//声明时可用stu stu1,相比于struct student stu1(也可用)简省(stu相当于struct student的别名)
typedef struct{
int a;
}stu;
//声明时只能用stu stu1,不能使用struct student stu1