[英]Xcode 5 c++ fstream (ifstream and ofstream) do not work
So i'm trying to read what's inside a file in my contents folder of my application: 因此,我试图读取应用程序目录文件夹中文件的内容:
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 ""*/
I do a "if" to check if the file is open, it's obviously not can. 我做一个“如果”来检查文件是否打开,显然不能。 you tell me what i'm doing wrong (i know the file path and its name are correct I used similar processes for image upload ect with SDL2 ect)
您告诉我我在做什么错(我知道文件路径及其名称正确,我使用类似的过程对SDL2 ect进行图像上传ect)
try this: 尝试这个:
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.