它不显示数据,只显示永无止境的循环



我得到了一个永无止境的循环。我在这个代码中做错了什么?非常感谢你帮我。

void viewStudents()
{
student *current = head;
do
{
if(current == NULL)
cout<<"Nothing here."<<endl;
else
{
cout<<"Student Name: "<<current->name<<endl;
cout<<"Student's ID Number: "<<current->studentNum<<endl;
cout<<"Student Degree: "<<current->studentDeg<<endl;
cout<<"Student Year Level: "<<current->studentYearLvl<<endl;
cout<<"Student Contact Number: "<<current->studentCont<<endl;
cout<<"Student Email: "<<current->studentEmail<<endl;
cout<<endl;
current = head->next;
}
}
while(current != NULL);
} 

问题是您一直将current设置为head->next
您想要的是将current设置为current->next

current = current->next;

相关内容

  • 没有找到相关文章

最新更新