News for hackers. Stuff that matters.
Re:Comp.lang.c Frequently Asked Questions by Thorrez on Monday September 13, 2021 @01:21AM (#28508092)
>Now, sizeof does measure the size of things, but, one of the obvious sizes you can measure is an array†, and that's definitely also the maximum index value for the array

Make sure to be careful and realize that sizeof my_array returns the number of bytes that my_array uses, not the number of elements. An array of 10 ints likely has sizeof == 40, while indexing past 9 would be undefined behavior.

Re:Comp.lang.c Frequently Asked Questions by tialaramex on Monday September 13, 2021 @04:03AM (#28508945)
Excellent point, that largely contradicts my earlier position in fact. I was thinking of an array of chars and should have considered that's only a special case.