【发布时间】:2015-09-06 14:18:57
【问题描述】:
我希望下面的行使用数组中给定的内容写入一个新文件
但进入一个名为logs的新文件夹:
char log_file_name[100]; /* this array contains the name of a new file */
ofstream write_to_log;
write_to_log.open (relative path, log_file_name , fstream::app);
如何让它工作?
【问题讨论】:
-
您需要一个系统调用来创建一个新文件夹。您使用的是 Windows、Linux 还是其他软件?您对使用 boost 库的解决方案感到满意吗?
-
Windows 10 64 位专业版。我忘了提到该文件夹已经存在。我只需要知道如何让 ofstream 使用数组中给出的内容作为文件名将文件写入该文件夹
-
因为我在你评论之前回答了......现在你也知道如何创建文件夹作为奖励;-)
标签: c++ arrays variables ofstream