|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include <stdio.h>
- #define LEN sizeof(struct student )
- int main(void)
- {
-
- struct student
- {
- int num;
- float score;
- struct student *next;
- };
-
- struct student stu1,stu2;
- struct student *pstu1,*pstu2,*pstu3;
- pstu1=&stu1;
- pstu2=&stu2;
-
- stu1.num=001;
- stu1.score =88.8;
- pstu1->next = &stu2;
-
- //stu2.next=NULL;// 如果这里不设定为 NULL , 那么stu.next 是指向哪里的呢 ?
- stu2.num =003;
- stu2.score =99.9;
- do
- {
- printf("%d %f",pstu1->num,pstu1->score);
- pstu1=pstu1->next;
- } while(pstu1->next!=NULL);
- return 0;
- }
- /*
- 运行结果
-
- *********************************************************
- 1 88.800003请按任意键继续. . .
- *********************************************************
- */
- /*
- 如果将上方 stu2.next=NULL; 注释掉的话,
- 会输出
- *********************************************************
- 1 88.8000033 99.900002请按任意键继续. . .
- *********************************************************
- 但是编译器会报错
- 请教如何打印此链表?
-
- */
复制代码
|
|