fstream的问题
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream fileOutput;
fileOutput.open("c:\mesh.txt");
//fileOutput.write("I am here",100);
fileOutput<<"I am here"<<endl;
fileOutput.close();
cin.get();
return 1;
}
本人就以上代码编译运行后,去察看c盘的mesh.txt文件发现,里面什么也没有.然后修改程序为:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream fileOutput;
// 将c盘去掉
fileOutput.open("mesh.txt");
//fileOutput.write("I am here",100);
fileOutput<<"I am here"<<endl;
fileOutput.close();
cin.get();
return 1;
}
编译运行后,察看mesh.txt,显示"I am here",成功了.可是为什么我加入c:就不行了呢?
如果不在当前目录下生成mesh.txt,那该怎么办?
谢谢.