@Lojcs@lemm.ee
link
fedilink
5
edit-2
3d

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

huf [he/him]
link
fedilink
English
33d

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

I don’t know, I just use printf

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.

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.

Create a post

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.
  • 1 user online
  • 158 users / day
  • 317 users / week
  • 704 users / month
  • 2.84K users / 6 months
  • 1 subscriber
  • 1.57K Posts
  • 34.8K Comments
  • Modlog