c++链表输出遍历出现乱码错误

c++链表遍历输出后面总会有乱码
stu* headinsert(stu* head,stu tem)
{  //为头部开辟堆区空间
   stu *pi=new stu;
   *pi=tem;
   if(head==NULL)
   {   head=pi;
    }
   else
   {   pi->next=head;
       head=pi;
   }
     return head;
}


void printfdate(stu* head)//遍历链表
{
    if(head==NULL)
    {  cout<<"链表不存在"<return;
    }
    stu *pb=head;
    while(pb!=NULL)
    {
        cout<num<<" "<name<<" "<gender<next;
    }
    return;
}


输出的链表后有乱码,代码会结束运行。

img

我是自学,希望能帮我看看。

你把这个printfdate函数中的最后一句 return去掉就行了