文件操作
文件操作的三大类:ofsteam
写,ifsteam
读,fsteam
读写
# include<fstream>
#include<iostream>
using namespace std;
int main() {
ofstream ofs;
ofs.open("abc.txt", ios::out);
ofs << "1" << endl;
ofs << "2" << endl;
ofs << "3" << endl;
ofs.close();
ifstream ifs;
ifs.open("abc.txt", ios::in);
char buf[1024] = {0};
while (ifs.getline(buf,sizeof(buf)))
{
cout << buf << endl;
}
}