166
submitted 2 months ago by [email protected] to c/[email protected]
you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 17 points 2 months ago
[-] [email protected] 40 points 2 months 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

[-] [email protected] 2 points 2 months ago

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

[-] [email protected] 8 points 2 months ago

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

[-] [email protected] 2 points 2 months ago

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

[-] [email protected] 10 points 2 months ago* (last edited 2 months ago)

Instead of this:

cout << "Hello world.\n";

You can do this:

cout << "Hello world." << endl;
[-] [email protected] 6 points 2 months ago

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

[-] [email protected] 1 points 2 months ago

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

[-] [email protected] 3 points 2 months ago

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

[-] [email protected] 1 points 2 months ago

same here. AP isn't standardized enough, apparently

[-] [email protected] 1 points 2 months ago* (last edited 2 months ago)

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

[-] [email protected] 7 points 2 months ago
[-] [email protected] 11 points 2 months ago

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

[-] [email protected] 1 points 2 months ago

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

[-] [email protected] 2 points 2 months ago

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

[-] [email protected] 2 points 2 months 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)

[-] [email protected] 3 points 2 months ago

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

[-] [email protected] 2 points 2 months ago

God bless your soul.

this post was submitted on 05 Apr 2025
166 points (95.1% liked)

Programmer Humor

36575 readers
692 users here now

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

Rules:

founded 5 years ago
MODERATORS