sizeof
is interpreted at compile time, and the compiler knows how the array was declared (and thus how much space it takes up). Calling sizeof
on a dynamically-allocated array will likely not do what you want, because (as you mention) the end point of the array is not specified.