Why is buffering in C++ important?

前端 未结 5 1052
离开以前
离开以前 2021-01-30 12:00

I tried to print Hello World 200,000 times and it took me forever, so I have to stop. But right after I add a char array to act as a buffer, it took le

5条回答
  •  一向
    一向 (楼主)
    2021-01-30 12:15

    If you have a buffer, you get fewer actual I/O calls, which is the slow part. First, the buffer gets filled, then one I/O call is made to flush the buffer. Will be equally helpful in Java or any other system where I/O is slow.

提交回复
热议问题