文章目录
前言
1.三种缓存方式的比较
1.无缓存
2.行缓存
3.快缓存
#include
#include
using namespace std;
int main(void)
{
fstream fs; // 定义了一个fs对象用来做后续操作
char str[] = “i love c++”;
char rstr[16] = {0};
fs.open(“1.txt”);
if (fs.is_open())
cout << “open success” << endl;
else
cout << “open fail” << endl;
// 文件写入
//fs.write(str, sizeof(str));
// fs << str << endl;
// 文件读出
// fs.read(rstr, sizeof(rstr));
fs >> rstr;
cout << "read content: " << rstr << endl;
fs.close();
return 0;
}