第11章 结构体与共用体 链表各结点的特点: 在内存中可以不连续,访问某结点应找上一结点提供的地址,每一结点有一指针变量存放下一结点的地址。 链表的每个结点实际上是一个结构体变量,它有若干成员组成,包括的内容有两部分: 数据部分:整、实、字符、结构体等类型。 指针变量:通常具有指向自身结构体类型的指针变量,此指针变量用来存放下一结点的地址,以便一环扣一环而形成链表。 struct student { int num; float score; struct student *next; }; 其中:next是成员名,是指针类型, 它指向struct student数据类型. 99101 89. 5 99103 90 99107 85 NULL num score next 简单链表 #include stdio.h #define NULL 0 struct student {long num; float score; struct student *next; }; void main( ) {struct student a,b,c,*head,*p; a.num=99101;a.score=89.5; b.num=99102;b.score=90; c.num=9910
原创力文档

文档评论(0)