很急的问题,还没有解决,论坛上朋友帮改的程序,可是我还是不能运行,用TC2.0,请大家帮我试下,谢谢了,在线等。。。
我一运行出现一屏幕的乱七八遭的东西,机器也叫,
大家请帮我改改吧,谢谢了。
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define null 0
#define len sizeof(struct kc)
struct kc{
int keid;
char kename[20];
int score;
struct kc *next;
}*p;
int n;
struct kc * create(void)
{
struct kc *p1,*p2;
struct kc *head;
/*struct kc *next; */
n=0;
p1=p2=(struct kc *)malloc(len);
/*p1=p2=&kc1; */
printf(" qing shuru kecheng id,score,name\n");
scanf("%d,%d,%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,%d,%s\n",&p1->keid,&p1->score,&p1->kename);
};
p2->next=null;
return(head);
}
void print(struct kc *head)
{
struct kc *p;
printf("fenshushi::");
p=head;
if(head !=null)
while(p!=null)
{
printf("%d,%s,%d\n",p->keid,p->kename,p->score);
p=p->next;
}
}
void main()
{
printf("shuru kecheng\n");
p=create();
print(p);
scanf("%d",&n);
return ;
}