#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;
#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