#include "stdio.h"
#include "malloc.h"
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
long num;
char name[10];
char sex[3];
int age;
struct student *next;
};
int n;
struct student *creat(int a)
{
struct student *head;
struct student *p1,*p2;
head=NULL;
while(n=0;n<a;n++)
{p1=(struct student*)malloc(LEN);
scanf("%ld,%s,%s,%d",&p1->num,p1->name,p1->sex,&p1->age);
if(n==0) head=p1;
else p2->next=p1;
p2=p1;
}
p1->next=NULL;
return(head);
}
void main()
{
struct student *p1,*head,*p2;
int n;
long t;
printf("please input the total number");
scanf("%d",&n);
head=p1=p2=creat(n);
printf("please input the num you want to delete");
scanf("%ld",&t);
while(t!=p1->num&&p1!=NULL){ p2=p1;p1=p1->next;}
if(p1==NULL) printf("the num you want to delete is not exist");
else
{
printf("%ld,\n%s,\n%s,\n%d\n",p1->num,p1->name,p1->sex,p1->age);
if(p1==head) head=p1->next;
else if(p1->next==NULL) p2->next=NULL;
else p2->next=p1->next;
}
}
我编的程序如上,可是系统老提示出错,哪位大侠帮我看一下