When using std::cout we typically return a new line at the end of each statement for cleanliness.
Despite std::endl being designed to serve this purpose, it is more efficient to use '\n'. This is because the later doesn’t flush the buffer after each std::cout. Doing this repeatedly is wasteful, inefficient and unnecessary.
Additionally, C++’s output system is designed to self-flush periodically, and it’s both simpler and more efficient to let it flush itself.
'\n' can be embedded in double quotes in an existing C-style string. It’s less code to produce the same result if you were to use std::endl. This makes the program more readable.
std::cout << "And that's all, folks!\\n";
// Using std::endl
std::cout << "And that's all, folks!" << std::endl;