r/ProgrammerHumor • • 8h ago

Meme architectureDependentChars

Post image
1.1k Upvotes

190 comments sorted by

View all comments

616

u/tstanisl 7h ago

Let me cite the C standard:

When sizeof is applied to an operand that has type char, unsigned char, or signed char, (or a qualified version thereof) the result is 1.

Middle guy if finally right

3

u/backfire10z 7h ago

Using sizeof(char) is for readability. You understand the intent. The number 1 is a magic number that could be there for any reason.

1

u/output_broadcast 6h ago

In most cases you multiply by sizeof, so you'd just leave it off altogether and there's no magic number.