#include
#include
#define LEN sizeof (struct stu)
#define NULL 0
struct stu
{int num;
char xm[10];
char sex[2];
struct stu *next;
};
int n;
struct stu *creat()
{struct stu *head,*p1,*p2;
n=0;
p1=p2=(struct stu *)malloc(LEN);
scanf("%d,%s,%s,&p1->num,&p1->xm,&p1->sex");
head=NULL;
while(p1->num!=0)
{n=n+1;
if(n==1)head=p1
;else p2->next=p1;
p2=p1;
p1=(struct stu *)malloc(LEN);
scanf("%d,%s,%s,&p1->num,&p1->xm,&p1->sex");
}
p2->next=NULL;
return(head);}
main()
{
struct stu *p;
p=creat();
printf("%d%s%s",p->num,p->xm,p->sex);
}
新手就20分全给了多谢
双引号的错误是失误,那也不是关键
|