帮帮忙看看这段代码有什么问题
#include<stdio.h>struct student
{
long num;
char *name;
char *sex;
int age;
struct student *nxet;
};
struct student *creat(void)
{
struct student *head,*p1,*p2;
printf("qing shu ru:\n");
p2=p1=(struct student *)malloc(sizeof(struct student));
scanf("%ld,%s,%s,%d",&p1->num,p1->name,p1->sex,&p1->age);
head=NULL;
while(p1->num!=0)
{
if(head==NULL)head=p1;
else p2->nxet=p1;
p2=p1;
p1=(struct student *)malloc(sizeof(struct student));
scanf("%ld,%s,%s,%d",&p1->num,p1->name,p1->sex,&p1->age);
}
p2->nxet=NULL;
free(p1);
return(head);
}
struct student *cut_del(struct student *head,long num)
{
struct student *a,*b;
a=head;
while(a->num!=num)
{
b=a;
a=a->nxet;
}
if(a==head)a=head->nxet;
else b->nxet=a->nxet;
return(a);
}
void print(struct student *a)
{
struct student *p;
p=a;
while(p!=NULL)
{
printf("\n%ld;%s;%s;%d\n",p->num,p->name,p->sex,p->age);
p=p->nxet;
}
}
void main()
{
struct student *a;
long aa;
a=creat();
printf("\nqing shu ru num:");
scanf("%ld",&aa);
a=cut_del(a,aa);
print(a);
getch();
}