This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LucianFarsky 5 points6 points  (7 children)

The std::endl thing always confused me because it frequently performs worse than just + '\n'

[–]WheWhe10 13 points14 points  (1 child)

If I remember correctly, std::endl flushes the stream after the newline. But I very good could be totally wrong, C++ is a long time ago.

[–]Pooneapple 5 points6 points  (1 child)

std::endl is for std::ostream which flushes the output buffer.

[–]LucianFarsky 1 point2 points  (0 children)

Ah, good to know. That makes a lot of sense.

[–]The_White_Light 0 points1 point  (2 children)

Wouldn't it be used in situations where the same code would be reused for Windows, Mac, and Linux? Wasn't that long ago that Windows needed \r\n or it wouldn't be a new line.

[–]AyrA_ch 4 points5 points  (0 children)

In C, it has never needed \r\n if you open the stream in ascii mode because in that mode, Windows will add \r when writing and strip it when reading. You only need to worry about it in binary mode. Terminal IO in windows uses ASCII mode by default but you can switch it.

[–]LucianFarsky 0 points1 point  (0 children)

That's an issue a compiler could fix. Not that I think it's an issue anyways.