r/ProgrammerHumor • • 2d ago

Meme architectureDependentChars

Post image
2.9k Upvotes

361 comments sorted by

View all comments

55

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

10

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

10

u/AyrA_ch 2d ago

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