2 ms·
>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
by Thorrez 5y ago
>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.
- tialaramex 5y agoExcellent 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.