请问如何新建一个文件夹并创建文件进行写入?
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream ofile;
ofile.open( "..\\b\\a.txt "); // fail!!!
if(!ofile)
{
cout < < "fail. " < <endl;
return 1;
}
ofile < < "haha " < <endl;
ofile.close();
ofile.clear();
cout < < "ok. " < <endl;
return 0;
}
运行后程序错误,请问如何在当前目录下新建b目录,并在b目录里写入a.txt?谢谢!
[解决办法]
google: c++ 新建文件夹
google: c++ 新建目录
自己搜下比发贴回贴快多了。