Array doesn't initialize with a curly braces in c++

Viewed 6231

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++

3 Answers
Related