C++ 读取文件数据和输出数据到文件

//读取
void read_file(const char *fn, string& content) 
{ 
 std::ifstream in(fn); 
 std::ostringstream tmp; 
 tmp << in.rdbuf(); 
 content = tmp.str(); 
 } 
 //写入
 void write_file(const char *fn, string& content) 
 { 
 std::ofstream fout(fn, std::ios::out); 
 fout<<content; 
 fout.close(); 
 }

 

posted @ 2020-07-09 17:22  十里坡剑神—》》》》  阅读(410)  评论(0编辑  收藏  举报