(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 比,省写 了 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)type struct {int x; int y; }test1; 这个不可以。 改 typedef ... 就可以了。 但也同 (3)一样,还要 写: test1 my_st; 才能用 my_st.x 和 my_st.y
struct LNode { ElemType data; struct LNode *next; }; 这样写的话,就是定义了一个名叫LNode的结构体;如果利用这个结构体定义一个变量就写成:struct LNode abc; typedef struct LNode { ElemType data; struct LNode *next; }LNode,*Linklist; 这个大括号后面的LNode是struct LNode这个结构体类型的别名,这个可以自己起名的,不过在这里比较特殊,别名和结构体的名字一致了,其实可以是任意的名字;*Linklist也是指向struct LNode这个结构体的一个指针;也是个别名 ,这时要是在声明一个结构体变量就可以写成 LNode abc;了不要用struct LNode abc了;