我正在尝试打开一个文件进行阅读:
cout << file_path << endl;
fstream myfile(file_path.c_str(), std::ios_base::in);
if (myfile.is_open())
cout << "Yahhy!! file Opend successfully" << endl;
else
cout << "Wohoo!! Wrong path" << endl;
输出是:
/home/umar/Desktop/DateFile/dha_dataset.gfp
Wohoo!! Wrong path
路径正确 - 文件存在,但未打开文件。问题出在我的代码中还是其他地方?
我在 Ubuntu 工作。