r/ProgrammerHumor 2d ago

Meme bugIntroducedDebugging

Post image
1.1k Upvotes

120 comments sorted by

View all comments

254

u/wolfjazz93 2d ago

Allocating 1 byte and assigning to int ptr. πŸ₯ΊπŸ˜­πŸ˜­

43

u/ClipboardCopyPaste 2d ago

uint8_t

19

u/yjlom 2d ago

char would be the correct answer, as the C standard doesn't mandate a byte be 8 bits (6 and 32 are very uncommon nowadays but not unheard of, and there's a few machines out there that get really creative).

7

u/mckenzie_keith 2d ago

So even on weird platforms where char is a 32 bit type, sizeof (char) is 1, right? I can't remember.

8

u/yjlom 2d ago

yeppers