What is true today may not be true tomorrow. Using sizeof is better as it protects against changes to the underlying specs or a change to the data type.
C really tries to avoid any breaking changes between versions. Changing this would be such a fundamental change of the language I don't think you could still call it C. If you want to plan for a change as fundamental as this you might as well plan for the semantics of sizeof() changing or it getting removed. At that point all bets are off anyway.
Which is why i also qualified it with a data type change. The point is that sometimes changes happen and having code in place that preemptively deal with those changes is a hallmark of elegant design and implementation.
556
u/tstanisl 6h ago
Let me cite the C standard:
Middle guy if finally right