As we know, these two lines seem to be equivalent. Indeed, if you write a hello world program and try to use both ways, you shall get the same result.
std::cout << "Hello world!" << std::endl;
std::cout << "Hello world!\n";
That means that every time we use std::endl, the buffer should be flushed. In other words, every time you print something, the system should flush the buffer, which I think is not a must, thus I suggest using “\n”, when you just want to print something.
However, notice that I strongly suggest you to use std::endl when debugging. Especially when it comes to memory management, std::endl is a must (maybe not in all debugging messages, but I suggest to use it for certainty).
Page created by G. (George) Samaras (DIT)