c语言建立和输出单链表程序中,为什么第一个数据没输出来?请各位高手帮忙看看,不胜感激!!!

[复制链接]
查看11 | 回复2 | 2011-10-17 22:02:33 | 显示全部楼层 |阅读模式
楼主你好,你的代码问题出了一点小问题:#include#include#define NULL 0struct student{int date;struct student *next;};void main(){struct student *head,*p,*r;int i,j,len=0;p=(struct student *)malloc(sizeof(struct student));printf("input the date:");scanf("%d",&p->date);while(p->date!=0){p=(struct studen...
回复

使用道具 举报

千问 | 2011-10-17 22:02:33 | 显示全部楼层
r->next=p; //r=p; //r=r-next,你现在的情况,第二个循环就把头节点覆盖了len++;...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行