In fact, when you say int A[5] = { 0 }; you say: Initialize the first element to zero. All other positions are initialized to zero due to aggregation initialization.
This line is the real responsibility that your array is filled with zeros: int A[5] = { };
That is why if you use int A[5] = { 1 }; , you will only have the first position initialized to 1.
rain_ Aug 17 '16 at 7:45 2016-08-17 07:45
source share