This may be a stupid question but how does the sizeof operator know the size of an array operand when you don\'t pass in the amount of elements in the array. I know it does
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.