Strange values while initializing array using designated initializers

前端 未结 5 1083
迷失自我
迷失自我 2021-02-07 05:57

When I initialize the array below all the output looks ok except for values[3]. For some reason values[3] initialized as values[0]+values[5]

5条回答
  •  猫巷女王i
    2021-02-07 06:24

    Try this code:

    int values[10];
    values[0]=197;
    values[2]=-100;
    values[5]=350;
    values[3]=values[0]+values[5];
    values[9]=values[5]/10;
    

    And then you print the array like you've done.

提交回复
热议问题