struct{ 成员表列 }变量名表列1,变量名表列2; 一个是声明一个结构体的原始用法, 一个是把结构体取了个别名。 例如 struct list{ int a; char c; stuct list *next; };(注意这个分号不能少) 这个结构体的类型名是struct list ;struct只是声明结构体需要的关键字。 如果你要定义一个结构体变量 你就可以 :结构体类型 变量名 如:struct list student; 你是不是觉得写struct list 觉得很麻烦? 那你就可以把struct list起个别名;就是绰号 可以这样 struct list{ int a; char c; stuct list *next; }; typedef struct list A;//给struct list起了个别名:A 那么你的A student; 就等同与 struct list student; 。 当然你也可以在声明一个结构体的时候给它起别名 typedef struct list{ int a; char c; struct list *next; }A;
$$$$$$$$$权威解释$$$$$$$$$$$$$
(1) struct { int x; int y; } test1; 定义了 结构体变量为 test1, test1.x 和 test1.y 可以在语句里用了。 (2) struct test {int x; int y; }test1; 定义了 结构体变量 test1, test1.x 和 test1.y 可以在语句里用了。 与 1 相比,1省写 了 test (3) typedef struct test {int x; int y; }text1,text2; 这种结构体的(类型)别名 叫 text1 或叫 text2 真正在语句里用的时候,还要写成如下形式: text1 test1; 然后再用 test1.x test1.y 或写 text2 test1; 然后再用 test1.x test1.y (4)typedef struct {int x; int y; }test1; 同 (3)一样,只是(4)省去了test真正在语句里使用时还要写成如下形式:
test1 my_st;然后,才能用 my_st.x 和 my_st.y