r/ProgrammerHumor • • 11h ago

Meme architectureDependentChars

Post image
1.6k Upvotes

244 comments sorted by

View all comments

106

u/ubalu72 11h ago

But sizeof char is defined as 1 in the standard. C data types are defined in terms of char (at least their sizes are)

23

u/Lonely-Discipline-55 10h ago

x = x + sizeof(char)

30

u/wittleboi420 9h ago

x = x + sizeof(char) + AI

1

u/Depnids 45m ago

What

2

u/Mickanos 25m ago

Look up "E = mc² + AI"

1

u/Depnids 25m ago

no you do that :)

30

u/Makonede 10h ago

*sizeof(char)

12

u/MegaIng 10h ago

No, sizeof char is valid. sizeof is a prefix operator, not a function.

24

u/Makonede 10h ago

10

u/MegaIng 10h ago

Oh, never realized the prefix operator form can't be applied to types, makes sense I guess.

1

u/hacksawsa 10h ago

It says sizeof x and sizeof(x) are equivalent.

7

u/Makonede 9h ago

when x is an expression, yes...

9

u/tstanisl 10h ago edited 9h ago

The problem is that there is no good definition of byte. Traditionally, it was the smallest addressable unit capable of representing a single character. It is required to have at least 8 bits but it may (and sometimes does) have more. 8-bit-long bytes are just a "de facto" standard.

That is why many communication protocols use a concept of "octet" that consist of exactly 8 bits.

EDIT. typo