this post was submitted on 05 Apr 2025
164 points (95.6% liked)
Programmer Humor
34850 readers
495 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
What the heck is endl???
std::endl
is used in output streams in C++ to end the line, using the os specific line termination sequence, and flush the buffer.The later one is a performance issue in many cases, why the use of
"\n"
is considered preferredDon’t most terminals flush the buffer on newline anyway?
It is the stream itself that is buffered, so the terminal does not handle the contents until the stream is flushed.
Maybe, but there is the internal buffer. Also, most I/O happens in files not consoles
Instead of this:
You can do this:
The fact that you used the namespace for
cout
but not forendl
inordinately bothers mesomething has replaced your lessthan signs with their HTML counterparts. such a silly thing to do in a code block
I think that's client side. Doesn't happen for me.
same here. AP isn't standardized enough, apparently
nah its a lemmy app on android that didn't get an update in ages
https://cplusplus.com/reference/ostream/endl/
Boy am I glad I don’t do C++ anymore. That string handling with the overloaded bitshift operator was wild.
Ah, so you're a println! kinda guy?
🦀 🦀🦀🦀🦀🦀🦀🦀
Alternatively:
https://en.cppreference.com/w/cpp/io/manip/endl
p.s. The site isn't entirely mobile friendly
(I'm a cppref lover tbh)
From memory it's a way to declare a line ending after your string.
God bless your soul.