0

我收到一条错误消息,我假设问题出在文件名上的 c/c++ 字符串上。start 是我创建的 C++ 字符串变量,我不能按原样使用它,在 inp.open 之后的括号中。start.c_str() 是我在讲座中被告知要做的事情,但这似乎不起作用。有任何想法吗?

   else if (start != "") {
        ifstream inp;
        inp.open(start.c_str());
        if (inp.fail()) { error("Could not open file"); }
        string row;
        while (getline(inp, row)) {
            filereadout.push_back(row);
        }
    }
}
4

0 回答 0