Why is buffering in C++ important?

前端 未结 5 1054
离开以前
离开以前 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:05

    The cout function contains a lot of hidden and complex logic going all the way down the the kernel so you can write your text to the screen, when you use a buffer in that way your essentially do a batch request instead of repeating the complex I/O calls.

提交回复
热议问题