Re: C++ Hello World

Originally Posted by
lloyd mcclendon
always prefer the "\n" over the endl since that .. i forget why i think it flushes the buffer or something.
It's actually the other way round. endl flushes the buffer, the newline character doesn't. It depends what to use where. As I understand it endl produces a very slight additional overhead as it causes the text to get printed here and now, whereas the newline character just hangs in the buffer until it is full, and/or it is flushed automatically.
The only problem there is with \n is that if your program is off to do other things that keep your system busy the buffer might not be flushed and your text might not get printed. Best bet is to always end the last output output statement with an 'endl'.
...as the previous post said... sorry hadn't seen that...
Mike says: "I'll treat this problem like my mattress and sleep on it."
- The Young Ones.
Bookmarks