Find size of array without using sizeof

&arr is a pointer to an array of 100 ints.

The [1] means “add the size of the thing that is pointed to”, which is an array of 100 ints.

So the difference between (&arr)[1] and arr is 100 ints.

(Note that this trick will only work in places where sizeof would have worked anyway.)

Leave a Comment