多个单链表调用后分别输入异常

第二个链表(项目b)输入投票人信息时有概率自动退出,请巨佬指点,感激不尽,

#include
#include
#include
using namespace std;


struct voter{
    int num; 
    string name;
    char choice;
    string cname;
    int status;
    voter *next;
};

struct choices{
    string name;
    int num;
    choices *next;
};

voter *head=NULL;//投票人信息链表 
choices *head1=NULL,*head2=NULL;//head1是a链表表头。head2是b链表表头 
    
void printmenu(){
    cout<<"欢迎来到投票系统"<"请选择功能"<"1.新建选项"<"2.新建投票人"<"3.查询投票人"<"4.删除投票人"<"5.修改投票问题"<"6.输出最高票选项"<"7,退出系统"<"添加在a/b项目?"<>ch;
    while(ch=='a'||ch=='b'){
        p=new choices;
        p->num=0;
        cout<<"请输入新选项"<>p->name;
        if(ch=='a'){
            if(head1==NULL){
                p->next=NULL;
                head1=p;
            }
            else{
                p->next=head1;
                head1=p;
            }
        }
        else{
            if(head2==NULL){
                p->next=NULL;
                head2=p;
            }
            else{
                p->next=head2;
                head2=p;
            }
        }
        cout<<"添加在a/b项目?或其余键回主页"<>ch;
    }
}

voter *createvoter(){
    voter *p,*q;
    choices *w;
    char ch;
    int x;
    cout<<"请输入投票项目(a或b)"<>ch; 
    while(ch=='a'||ch=='b'){
        int judge=1;
        p= new voter;
        p->choice=ch;
        cout<<"请输入投票人姓名"<>p->name;
        for(voter *j=head;j!=NULL;j=j->next){
            if(j->name==p->name&&j->choice==p->choice){
                cout<<"不能重复投票!"<judge=0;
                break ; 
            }
        } 
        if(judge==0) break;
        cout<<"请输入其编号"<>p->num; 
        
        cout<<"是否为Vip?"<"1.不是Vip\t2.是Vip"<>p->status;
        cout<<"选择喜欢的内容:"<if(ch=='a') w=head1;
        else w=head2;
        choices *u=w;
        for(int i=1;u!=NULL;u=u->next,i++){
            cout<'.'<name<<"  ";
        }
        cout<>x;
        for(int i=0;iw=w->next;
        }
        if(p->status==2){
            w->num+=3;
            p->status=3;
        } 
        else w->num+=1;
        p->cname=w->name;
        if(head!=NULL) q->next=p;
        else {
            p->next=NULL;
            head=p;
        }
        q=p;
        cout<<"请输入投票项目(a或b或其余键回主页)"<>ch;
    }
    return head;
}


int main(){
    int n=0; 

    while(1){
        printmenu(); 
        int o;
        cin>>o;
        switch(o){
            case 1:createchoices();break;
            case 2:head=createvoter();break;//输入b项目后会自动退出
            case 3:searchvoter();break;
            case 4:deletevoter();break;
            case 5:changevoter();break;
            case 6:printresult();break;
            case 7:{
                cout<<"欢迎下次使用!"<"pause");
    }
 }



用代码块功能插入代码,请勿粘贴截图