看了《C++编程对缓冲区的理解》,自己试了下,结果为大小4KB。

#include <fstream>

using namespace std;

int main()
{
	ofstream outfile("test.txt");
	for (int i = 0; i < 4096; i++)
		outfile << 'a';
	system("PAUSE");
	outfile << 'b';
	system("PAUSE");

	return 0; 
}

在第一次出现“请按任意键继续. . .”时打开“test.txt”文件,发现是空的,按回车键后再打开是“aaaa....aaaa”,继续按回车键,打开是“aaaa....aaaab”。

把4096改成4095后:

在第一次出现“请按任意键继续. . .”时打开“test.txt”文件,发现是空的,按回车键后再打开还是为空的,继续按回车键,打开是“aaaa....aaaab”。

 

相关文章:

  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2021-07-03
  • 2021-05-31
  • 2021-09-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
  • 2022-12-23
  • 2021-08-08
相关资源
相似解决方案