第九章用户建立的数据类型2.pptVIP

  • 15
  • 0
  • 约1.14千字
  • 约 15页
  • 2017-04-28 发布于四川
  • 举报
第九章用户建立的数据类型2

;§9.4 用指针处理链表 ;用结构体建立链表的结点(例):  struct student   { int num;     float score;     struct student *next ;}; 其中成员num和score用来存放结点中的有用数据(用 户需要用到的数据),next是指针类型的成员,它指 向struct student类型数据。;9.4.2 建立简单的静态链表 ; 9.4.3 建立动态链表 ;建立链表的函数如下: #include stdio.h #include malloc.h #define NULL 0 //令NULL代表0,用它表示“空地址 #define LEN sizeof(struct student) //令LEN代表struct //student类型数据的长度 struct student { int num; float score; struct student *next; }; int n; //n为全局变量,本文件模块中各函数均可使用它;struct student *creat( ) { struct student *head,*p1,*p2; n=0; p1=p2=(struct student*)malloc(LEN); sca

文档评论(0)

1亿VIP精品文档

相关文档