我試圖打開一個文件進行讀操作: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