码迷,mamicode.com
首页 > 其他好文 > 详细

结构体指针

时间:2015-12-25 19:04:01      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:

 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 }

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

结构体指针

标签:

原文地址:http://www.cnblogs.com/-lyric/p/5076460.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!