I want to initialize all the array elements with just one value so I wanted to use option 1, the shorter version. But that does not seem to working. However option 2 works. Can anybody please explain what's going wrong when I try to initialize via option 1..
int main()
{
int arr[5] = { 2 }; // option 1
int arr1[5] = { 2, 2, 2, 2, 2 }; //option 2
for (int i = 0; i < 5; i++)
cout << arr[i] << " ";
for (int i = 0; i < 5; i++)
cout << arr1[i] << " ";
}