In the C++ primer book, in chapter (1), it mentions the following:
endl is a special value, called a manipulator, that when written t
When using std::cout, the operand used after the output operator ( << ) are stored in a buffer and are not displayed onto the stdin (usually terminal, or the command prompt) until it comes across std::endl or std::cin, which causes the buffer to be flushed, in the sense, display/output the contents of the buffer onto the stdin.
Consider this program:
#include
#include
int main(void)
{
std::cout << "Hello, world";
sleep(2);
std::cout << std::endl;
return 0;
}
The output obtained will be:
after 2 seconds
Hello, World