如何使用fstream在另一个目录中创建一个TXT文件?
我想使用 fstream 在另一个文件夹中创建一个 txt 文件。你一定知道rpg游戏吧?必须有一个保存数据的系统。为了保存我们在游戏中的进度,如果保存数据文件与exe文件混合在一起,请不要高兴。我尝试过各种方法。
例如
cin >> Save_Data;
ofstream Char_Pertama (("/RPG GAME PERCOBAAN/Save Data", Save_Data), ios :: out);
cin >> Save_Data;
ofstream Char_Pertama ("/RPG GAME PERCOBAAN/Save Data"); (Save_Data, ios :: out);
,我也尝试过这个...
cin >> Save_Data;
ofstream Char_Pertama ("../RPG GAME PERCOBAAN/Save Data/Save_Data", ios :: out);
但是,txt 文件不能由我们来命名。 我希望,我们可以随意命名文件名。
请帮我解决这个问题,您的建议将对我非常有帮助
I want to create a txt file in another folder using fstream. You must know rpg games, right? there must be a save data system. to save our progress in the game, don't be happy if the save data file is mixed with the exe file. I've tried various ways.
for example
cin >> Save_Data;
ofstream Char_Pertama (("/RPG GAME PERCOBAAN/Save Data", Save_Data), ios :: out);
cin >> Save_Data;
ofstream Char_Pertama ("/RPG GAME PERCOBAAN/Save Data"); (Save_Data, ios :: out);
I have tried this one too...
cin >> Save_Data;
ofstream Char_Pertama ("../RPG GAME PERCOBAAN/Save Data/Save_Data", ios :: out);
But,the txt file is not up to us to name it.
I wish, we can make the filename as we like.
please help me to solve this, your suggestions will be very helpful for me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎正在寻找一种读取文件名的方法,然后将该文件名连接到某个固定路径。尝试
You seem to be looking for a way to read in a file name, and then concatenate that filename to some fixed path. Try