做的小链表 然后运行了能输出结果之后就停止工作~怎么回事啊 c++
#include <iostream>//迷之超限?!using namespace std;
struct student
{
int num;
int score;
student *next;
};
int main ()
{
void creat(student a[]);
student a[10];
for (int i=0;i<10;i++)
{
cout<<"请输入学生"<<i+1<<"的学号及分数"<<endl;
cin>>a[i].num>>a[i].score;
}
creat(a);
return 0;
}
void creat(student a[10])
{
void print (student a[10],student *p);
student *head,*p;
head=&a[0];
p=head;
int i=0;
for (i=0;i<9;i++)
{
a[i].next=&a[i+1];
}
a[10].next=NULL;
print (a,p);
}
void print (student a[],student *p)
{
while (p!=NULL)
{
cout<<p->num<<" "<<p->score<<endl;
p=p->next;
}
}