猜成语(语言-c++)

打不开外部文件
我不知道为什么打不开文件,如果是E:\22c++\B07.txt或E:\22c++\B07.txt,开始游戏后就是输出NO!,如果是E:\22c++\B07.txt,开始游戏后没有谜面,3次错误后出现提示,提示是死循环

int Game::star(){
    srand(time(0));//给谜面随机数
    int n=0;//n存储谜语个数
    
    ifstream fin;//?
    fin.open("E:\\22c++\\B07.txt");//打开外部文件
    if(!fin){
        cout<<"No!";//判断是否引入 
        return 0; 
    }
    while(fin){
        getline(fin,str1);//?
        n++;
    }
    fin.close();//?
    
    while(true){
        fin.open("E:\\22c++\\B07.txt");
        int num=rand()%n;//随机产生谜面
        for(int i=0;i'!');//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        getline(fin,str2,'@');//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        getline(fin,str3,'#');//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        getline(fin,str4);//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    {
    
        Riddle g(str1,str2,str3,str4);//根据读入生成对象
         
    //}

    //判断!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    while(true)//开始循环 
    {
        int j=0;//次数 
        cout<<"请输入答案:"<>str2;//开始答题 
        j++;//计数增加 
        while(str2!=g.key)//出错了 
        {
            if(j<3)//未开始提示 
            {
                cout<<"出错了"<"请输入答案:"<>str2;
                j++;
            }
            else if(j==3)//未超出提示次数 (1级提示 ) 
            {
                cout<"给你提示吧:"<"请输入答案:"<4)//未超出提示次数 (2级提示 ) 
            {
                cout<"再给你提示吧:"<"请输入答案:"<4)//超出提示次数 
            {
                cout<<"出错了!是1/否2出谜底?"<>e;
                while(e!='1'&&e!='2')//如果乱输入 
                {
                    fflush(stdin);//清空输入缓冲区 
                    cout<<"请输入1或2,是1/否2出谜底?:"<>e;
                }
                while(e=='2')//不出谜底 
                {
                    fflush(stdin);//清空输入缓冲区
                    cout<"再来!加油!"<>str2;
                    j++;    
                }
                while(e=='1')//出谜底 
                {
                    fflush(stdin);//清空输入缓冲区
                    cout<"答案是:"<"继续努力!"<"下一题!"<"答对了!"<"再来答题吧!"<"cls");//清屏
        }
        break;
    }
    fin.close();//关闭外部文件 
}
}
} 

看看文件是否存在呢,注意路径和后缀

while改为if

                while(e!='1'&&e!='2')//如果乱输入 
                {
                    fflush(stdin);//清空输入缓冲区 
                    cout<<"请输入1或2,是1/否2出谜底?:"<<endl;
                    cin>>e;
                }
                while(e=='2')//不出谜底 
                {
                    fflush(stdin);//清空输入缓冲区
                    cout<<endl<<"再来!加油!"<<endl;
                    cin>>str2;
                    j++;    
                }
                while(e=='1')//出谜底 
                {
                    fflush(stdin);//清空输入缓冲区
                    cout<<endl<<"答案是:"<<g.key<<endl;
                    cout<<"继续努力!"<<endl;
                    cout<<"下一题!"<<endl; 
                    break;