链表 改错 第一次出现这样的错误提示。
程序运行时显示:The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one #include<iostream.h>
#include<string.h>
struct student
{
char name[4];
char address[10];
float tel;
student *next;
};
void main()
{
student *create(void);
void print(student *head);
void del(student *head);
student *head;
head=create();
print(head);
del(head);
}
student *create(void)
{
char name[4];
student *head,*p1,*p2;
head=NULL;
cout<<"input the name:";
cin>>name;
while(strcmp(name,"end")!=0)
{
p1=new student;
strcpy(p1->name,name);
cout<<"input other information:";
cin>>p1->address>>p1->tel;
if(head==NULL)
head=p2=p1;
else
{
p2->next=p1;
p2=p1;
}
cout<<"input the name:";
cin>>name;
}
if(head!=NULL)
p2->next=NULL;
return (head);
}
void print(student *head)
{
student *p;
if(head==NULL)
cout<<"it is not exist";
p=head;
while(p!=NULL)
{
cout<<p->name<<" "<<p->address<<" "<<p->tel<<endl;
p=p->next;
}
}
void del(student *head)
{
student *p;
while(head!=NULL)
{
p=head;
head=head->next;
delete p;
}
}