1. 程式人生 > >【C/C++】檔案操作

【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