【C/C++】文件操作

Backto C/C++ Index

引入头文件

#include   

然后 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();

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

  • OpenCV 读写 YAML 文件

Ref

  • C++中Txt文件读取和写入 : 知识点讲解,排版很乱
  • c++对txt文件的读取与写入 : 例子可以, 直接copy过来改一下场景就可以用

你可能感兴趣的:(file,operations,C/C++)