this post was submitted on 20 Nov 2024
232 points (98.3% liked)

Programmer Humor

32542 readers
546 users here now

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

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 5 points 1 day ago* (last edited 1 day ago) (3 children)

Kind of unrelated, why does c sometimes fail to print if it hits a breakpoint right after a print while debugging? Or if it segfaults right after too iirc

[–] [email protected] 3 points 21 hours ago (1 children)

does anything flush the buffers after the print, but before the break? otherwise, if the stream you're printing to is buffered, you're not necessarily gonna see any output

[–] [email protected] 3 points 20 hours ago

I don't know, I just use printf

[–] [email protected] 5 points 1 day ago

Without knowing the details of C, I've seen this in other languages and it's usually something with missing a flush or a buffered output mode or something like that.

[–] [email protected] 2 points 1 day ago

Im pretty sure its because of char 13 (carriage return). This char sets cursor to the start of the line overwriting whatever was printed there (in most terminals). I belive that some error messages use this char and when you print something the char at the begining or end of the error message overwrites your message. A workaround is simply printing a newline after or before your message.