163
you are viewing a single comment's thread
view the rest of the comments
[-] unlawfulbooger@lemmy.blahaj.zone 17 points 1 week ago
[-] vapeloki@lemmy.world 40 points 1 week ago

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 preferred

[-] xigoi@lemmy.sdf.org 2 points 1 week ago

Don’t most terminals flush the buffer on newline anyway?

[-] ClemaX@lemm.ee 8 points 1 week ago

It is the stream itself that is buffered, so the terminal does not handle the contents until the stream is flushed.

[-] vapeloki@lemmy.world 2 points 1 week ago

Maybe, but there is the internal buffer. Also, most I/O happens in files not consoles

[-] hellfire103@lemmy.ca 10 points 1 week ago* (last edited 1 week ago)

Instead of this:

std::cout << "Hello world.\n";

You can do this:

std::cout << "Hello world." << endl;
[-] Daedskin@lemm.ee 6 points 1 week ago

The fact that you used the namespace for cout but not for endl inordinately bothers me

[-] ReversalHatchery@beehaw.org 1 points 1 week ago

something has replaced your lessthan signs with their HTML counterparts. such a silly thing to do in a code block

[-] fubbernuckin@lemmy.dbzer0.com 3 points 1 week ago

I think that's client side. Doesn't happen for me.

[-] Cyberfishofant2@lemm.ee 1 points 1 week ago

same here. AP isn't standardized enough, apparently

[-] ReversalHatchery@beehaw.org 1 points 1 week ago* (last edited 1 week ago)

nah its a lemmy app on android that didn't get an update in ages. probably just uses a faulty markdown renderer

[-] gon@lemm.ee 7 points 1 week ago
[-] unlawfulbooger@lemmy.blahaj.zone 11 points 1 week ago

Boy am I glad I don’t do C++ anymore. That string handling with the overloaded bitshift operator was wild.

[-] vext01@lemmy.sdf.org 1 points 1 week ago

Ah, so you're a println! kinda guy?

πŸ¦€ πŸ¦€πŸ¦€πŸ¦€πŸ¦€πŸ¦€πŸ¦€πŸ¦€

[-] SqueakyBeaver@lemmy.blahaj.zone 2 points 1 week ago

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)

[-] allywilson@lemmy.ml 3 points 1 week ago

From memory it's a way to declare a line ending after your string.

[-] jaybone@lemmy.zip 2 points 1 week ago

God bless your soul.

this post was submitted on 05 Apr 2025
163 points (95.5% liked)

Programmer Humor

35080 readers
114 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS