求助,链表问题
#include<iostream.h>class student
{
public:
char *name;
char *number;
int score;
student *next;
};
void main()
{
student *p=new student;
cin>>p->name>>p->number>>p->score;
student *head=p;
for(int i=0;i<1;i++)
{
student *q=new student;
cin>>q->name>>q->number>>q->score;
p->next=q;
p=p->next;
}
p=head;
while(p!=0)
{
cout<<p->name<<" ";
cout<<p->number<<" ";
cout<<p->score<<" ";
cout<<endl;
p=p->next;
}
}
运行不通过,请高手指点一下……