关于fstream、ifstream、ofstream读写文本文件、二进制文件详解
时间:2018-06-29 20:57:27
收藏:0
阅读:515
fstream、ifstream、ofstream是c++中关于文件操作的三个类
fstream类对文件进行读操作和写操作
打开文件
fstream fs("要打开的文件名",打开方式);
或者
fstream fs;
fs.open("要打开的文件名",打开方式);
例子:
- fstream fs("test.txt"); //用文本方式打开一个文件用于读写
- fstream fs("test.txt",ios::binary); //用二进制方式打开一个文件用于读写
原文:https://www.cnblogs.com/smallredness/p/9245353.html
评论(0)