很急的,占用大家点时间,请帮忙改改程序,谢谢了,动态链表的建立与输出。再线等
现在编译可以通过了,可是得不到输入的结果,请帮忙看看,谢谢了
#include<string.h>
#include<stdio.h>
#define null 0
#define len sizeof(struct kc)
struct kc{
int keid;
float score;
char kename[20];
struct kc *next;
};
int n;
struct kc *create(void)
{
struct kc *p1,*p2;
struct kc *head;
int n=0;
p1=p2=(struct kc *)malloc(len);
printf(" qing shuru kecheng id score name\n");
scanf("%d,%f,%s",&p1->keid,&p1->score,&p1->kename );
head=null;
while(p1->keid !=0)
{
n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct kc*)malloc(len);
scanf("%d,%f,%s\n",&p1->keid,&p1->score,&p1->kename);
};
p2->next=null;
return(head);
}
print(struct kc *head)
{
struct kc *p;
printf("fenshushi::");
p=head;
if(head !=null)
do
{
printf("%d,%f,%s\n",p->keid,p->score,p->kename);
p=p->next;
}while(p!=null);
}
main()
{
printf("shuru kecheng\n");
create();
print(create());
}