Arial Swploit
2020-05-25 10:41
采纳率: 100%
浏览 237

C++问题:输出结果是”ECHO处于打开状态“,这个怎么办?

有一段函数,使输出了这段:”ECHO处于打开状态“

vector<string> Student::find_Student(const char * stu_name)
{
    string openname = string(stu_name) + "/" + string(stu_name) + "_name.txt";
    string openage = string(stu_name) + "/" + string(stu_name) + "_age.txt";
    string openscore = string(stu_name) + "/" + string(stu_name) + "_score.txt";
    string opensex = string(stu_name) + "/" + string(stu_name) + "_sex.txt";
    string tname, tage, tscore, tsex;

    ifstream inname;
    inname.open(openname.c_str());
    if (!inname)
    {
        cout << "未找到该学生!" << endl;
    }
    getline(inname, tname);
    inname.close();

    ifstream inage;
    inage.open(openage.c_str());
    if (!inage)
    {
        cout << "未找到该学生!" << endl;
    }
    getline(inage, tage);
    inage.close();


    ifstream inscore;
    inscore.open(openscore.c_str());
    if (!inscore)
    {
        cout << "未找到该学生!" << endl;
    }
    getline(inscore, tscore);
    inscore.close();

    ifstream insex;
    insex.open(opensex.c_str());
    if (!insex)
    {
        cout << "未找到该学生!" << endl;
    }
    getline(insex, tsex);
    insex.close();

    info2.push_back(tname);
    info2.push_back(tage);
    info2.push_back(tscore);
    info2.push_back(tsex);
    cout << info2.back() << endl;
    return info2;
}

在倒数第三行,cout << info2.back() << endl;
这一行输出了”ECHO处于打开状态“(info2是一个vector数组)。
(tsex变量储存学生性别,true为男,false为女,但是储存学生性别的文件中的内容是”男“,tsex变量储存在vector数组最后一个位置)
请问如果解决?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题