3 ms·
It's because you can initialize the array with particular values, like: `type a[3] = { 1 , 2, 3 };`. But I agree that it would make sense to fill the array (or
by bArray 9y ago
It's because you can initialize the array with particular values, like: `type a[3] = { 1 , 2, 3 };`.
But I agree that it would make sense to fill the array (or have an easier method to do that), it may just be an argument of speed. I think OSes generally hand over uninitialized memory zero'ed out to prevent reading of memory from previous programs - so it's a case of allocating the memory space and then continuing, as opposed to setting values for each position.
- jotux 9y agoUntil now, I always thought this: int array[5] = {X}; Could be be used to set all values of the array to X, but have never used it for anything other than 0. That's somewhat surprising behavior.