[英]Why fstream is not inherited from ifstream and ofstream in c++?
[英]Xcode 5 c++ fstream (ifstream and ofstream) do not work
因此,我試圖讀取應用程序目錄文件夾中文件的內容:
std::string username;
std::ifstream user("../Resources/username.txt");
user >> username;
user.close(); /*here I do a breakpoint to check the value of username and it's ""*/
我做一個“如果”來檢查文件是否打開,顯然不能。 您告訴我我在做什么錯(我知道文件路徑及其名稱正確,我使用類似的過程對SDL2 ect進行圖像上傳ect)
嘗試這個:
std::string username;
std::ifstream user("C://test.txt", std::ifstream::in);
user >> username;
user.close(); /*here I do a breakpoint to check the value of username and it's ""*/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.