【C/C++】文件操作

Backto C/C++ Index

引入头文件

#include <fstream>  

然后 Read 用 ifstream, Write 用 ofstream

ifstream infile;
ofstream outfile;

// common operarions
file.open("file_path.text", MODE);
// do your bussiness here
file.flush(); // if write
file.close();

更简介高级的方式,还是使用封装好的库吧.比如

Ref

猜你喜欢

转载自blog.csdn.net/baishuo8/article/details/83382790