C语言中静态链表的定义为:所有的结点都是在程序中定义的,不是临时开辟的,也不能用完后释放,这种链表称为“静态链表”。
代码如下:
#include <stdio.h>
struct Student{
int num;
float score;
struct Student *next;
};
int main(){
struct Student a, b, c, *head, *p;
a.num = 10101;
a.score = 89.5;
a.num = 10103;
a.score = 90;
a.num = 10107;
a.score = 85;
head = &a;
a.next = &b;
b.next = &c;
c.next = null;
p = head;
do{
printf("%ld%5.1f\n", p->num, p->score);
p = p->next;
}while(p!=null);
return 0;
}