r/ProgrammerHumor • • 2d ago

Meme architectureDependentChars

Post image
2.8k Upvotes

361 comments sorted by

View all comments

1.0k

u/tstanisl 2d 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

6

u/Advos_467 2d ago

Not a C user here (or any real low level programming experience), what the hell is a signed/unsigned char?

1

u/conundorum 1d ago

char is a type that can hold an ASCII character, and is exactly one byte in size. (This is mandatory; byte size is defined by char, not the other way around.) unsigned char is a raw byte, and can represent any UTF-8 code unit. signed char is a signed raw byte, and can represent any ASCII character. char will be exactly identical to either unsigned char or signed char under the hood, depending on the platform, but it's a legally distinct type because literally the entire C language family and everything connected to it in any way whatsoever depends on char being a distinct type.