Input and output buffer in C++

In c++ we hear a lot that there are input and output buffers maintained, and there is also flushing process for the buffer.
Can you explain the concept of buffers and their flushing…

also, I have heard that we should use “\n” in place of endl… as endl flushes out the buffer and slows down the program.

Reference: