(和另一贴不同)帮忙看一下,这是哪里错了,刚学链表,不知道那错的地方什么意思!!!
#include<stdio.h>#include<malloc.h>
struct student
{long num;
int scor;
struct student *next;
};
#define len sizeof(struct student)
void main()
{ int n=0,y;
long x;
struct student *p1,*p2,*head=NULL;
scanf("%ld,%d",&x,&y);
while(x!=0)
{ p1=(struct student *)malloc(len);
p1->num=x;
p1->scor=y;
n++;
if(n==1)
head=p2=p1;
else
{p2->next=p1;
p2=p1;
}
scanf("%ld,%d",&x,&y);
}
p2->next=NULL;
struct student *p3;
p3=head;
while( p3->next!=NULL)
{printf("%ld,%d",p3->num,p3->scor);
p3=p3->next;}
printf("\n");
}
[ 本帖最后由 浪漫横行 于 2013-5-20 13:05 编辑 ]