结构体指针

 1 #include<stdio.h>
 2 struct stu{
 3     int num;
 4     float score;
 5     struct stu* next;
 6 };
 7 
 8 int main() {
 9     struct stu a, b, c, *head, *p;
10     a.num = 10101;
11     a.score = 89.5;
12     b.num = 10103;
13     b.score = 90;
14     c.num = 10107;
15     c.score = 85;
16     head = &a;
17     a.next = &b;
18     b.next = &c;
19     c.next = NULL;
20     p = head;
21     do {
22         printf("%d %5.1f\n", p -> num, p ->score);
23         p = p->next;//使p指向下一个结点
24     } while(p != NULL);
25     return 0;
26 }

上面是个简单的静态链表;

posted on 2015-12-25 17:12  _阿赞  阅读(196)  评论(0编辑  收藏  举报