zoukankan      html  css  js  c++  java
  • 测试缓冲区多大时刷新

    看了《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”。


    /**************************************************************************
                      原文来自博客园——Submarinex的博客: www.cnblogs.com/submarinex/               
      *************************************************************************/

  • 相关阅读:
    发光二极管
    续流二极管作用及工作原理
    python backtrace注意事项
    docker tips
    direct stdin and stdout
    python skill
    mysql comments
    python dict
    python list and tuple
    Python library
  • 原文地址:https://www.cnblogs.com/submarinex/p/2340682.html
Copyright © 2011-2022 走看看