Confusion about array initialization in C

后端 未结 7 1325
不知归路
不知归路 2020-12-12 18:13

In C language, if initialize an array like this:

int a[5] = {1,2};

then all the elements of the array that are not initialized explicitly w

7条回答
  •  长情又很酷
    2020-12-12 18:14

    The assignment a[2]= 1 is an expression that has the value 1, and you essentially wrote int a[5]= { 1 }; (with the side effect that a[2] is assigned 1 as well).

提交回复
热议问题