ofstream写入数据

来源:互联网 发布:域名做企业邮箱 编辑:程序博客网 时间:2024/06/06 10:41
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ofstream outfile;
outfile.open("1.txt");//1.txt在与工程中debug位于同一级别的目录层中,1.txt可以不用创建程序生成时自己创建,
if (!outfile)
{
cout<<"不能打开1.txt文件\n";
}
outfile<<1111<<"  "<<11111<<endl;
outfile.close();
return 0;

}

////////outfile.open("C:\\Users\\Robin\\Desktop\\1.txt");也可以是任意一个目录,如桌面上的1.txt

原创粉丝点击