帮忙看看:是编译器问题还是程序问题
刚copy钱能的c++上的一道例题,是关于连表的问题,可是奇怪出现了
每当我运行是,总是到一半时候弹出“发送错误报告的对话框”晕啊,哪未看看到底是什么问题?
源程序如下:
#include<iostream.h>
struct Student
{
long number;
float scorse;
Student *next;
};
Student *head;
Student *Creat()
{
Student *ps;//创建结点指针
Student *pEnd;//链尾指针,用于其后面插入结点
ps=new Student ;//新建一个结点,准备插入链表
cin>>ps->number>>ps->scorse;
head=NULL; //一开始链表为空
pEnd=ps;
while(ps->number!=0)
{if(head==NULL)
head=ps;
else
pEnd=ps;
ps=new Student;
cin>>ps->number>>ps->scorse;
}
pEnd->next=NULL;
delete ps;
return(head);
}
void ShowList(Student *head)
{
cout<<"now the items of list are\n";
while(head)
{
cout<<head->number<<","<<head->scorse<<endl;
head=head->next;
}
}
void main()
{
ShowList(Creat());
}