//将文件写入txt中
#include<iostream>
#include<fstream>
using namespace std;
struct Box
{
int x;
int y;
int width;
int height;
};
int main()
{
Box box[3] =
{
{23,45,100,150
},
{34,90,25,25
},
{60,75,120,115
}
};
ofstream fout("result.txt");
if(!fout)
{
cout<<"文件打开失败!"<<endl;
return -1;
}
for(int i=0;i<3;i++)
{
fout<<box[i].x<<"\t"<<box[i].y<<"\t"<<box[i].width<<"\t"<<box[i].height;
fout<<endl;
}
fout.close();
return 0;
}
网友评论