声明流对象
ofstream ofile; //说明一个输出流
ofstream outfile("图像像素信息.txt",ios::in|ios::trunc);
这是通过构造函数打开文件
ios::trunc 废弃当前文件内容
比如:
ofstream ofile;
ofile.open("test.txt",ios::out);
相当于: //ofstream ofile("test.txt",ios::out);
ios::trunc 删除先前文件中的内容
例如:ofstream file("book.txt",ios::trunc). 它是删除book.txt里面内容的。