版权声明:版权所有,转载请注明出处 https://blog.csdn.net/songchuwang1868/article/details/83146618
1、头文件
#include<fstream>
2、fstream对象
fstream out("./output.out");//没有文件返回out==0,不会创建文件
out<<"hello world"<<endl;
要想fstream对象在没有文件时自动创建对象:
fstream out("output.out",ofstream::out);
//或者
fstream out("output.out",ofstream::app);
3、ofstream对象
ofstream out(“./output.out”);//没有文件创建文件