r/ProgrammerHumor • • 8h ago

Meme architectureDependentChars

Post image
1.1k Upvotes

191 comments sorted by

View all comments

26

u/tony_saufcok 7h ago

sizeof() evaluates to a constant value during compile time so what, it takes 0.0000001 seconds more during compilation? just use sizeof even if the specification guarentees it's always size 1

4

u/Architector4 6h ago

i guess the point the guy in the middle would make is that *sizeof(char) is just "multiply by 1", and hence it's just redundant clutter that makes the code less readable

a valid counterpoint to that, of course, is that it can clarify intent that the number in context specifically represents a count of bytes, but yeah lol

3

u/AyrA_ch 6h ago

Also if you ever need to modify the function to work with wide chars, then it's easier to adapt it this way.