Originally Posted by
lilhawk2892
whats the difference between \n and endl they both do the same thing?
endl prints a newline AND flushes the output stream.
so you can do
Code:
for (int i = 0; i < 200; ++i)
{
cout << i << '\n';
if (i == 66)
{
// crash here
ASSERT(false);
}
}
and your output may or may not get to 66 depending on your systems buffering.
but if you do
Code:
for (int i = 0; i < 200; ++i)
{
cout << i << endl;
if (i == 66)
{
// crash here
ASSERT(false);
}
}
you're guarenteed to get 0-66 printed out. Of course, flushing the buffer causes a slight performance penalty. Profile to find out if it affects you.