我试图打开一个文件进行读操作:fstream的不打开文件
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工作。
可能你没有权限阅读? – codeling
创建一个新文件来测试。 – DogDog
@nyarlathotep我有权限 – OOkhan