I'm learning c++ and I've encountered the following strange thing:
If I initialize array like the book says
int my_array[5] = {10}
every array field is still initialized to zero, when it should be ten.
If I initialize it in a loop, it works as intended
What is happening? I'm using Ubuntu and compiling with g++
What you observe is correct: the remaining items of the array are initialized to 0, according to the standard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With