Why is this array having all remaining values initialized to zero?

后端 未结 4 1435
难免孤独
难免孤独 2020-12-02 02:39

Hello I am a beginner in C programming language, recently i started learning arrays, I have studied that by default all values in an int ar

4条回答
  •  情深已故
    2020-12-02 02:45

    C11 6.7.9 Initialization p19 covers this (my emphasis)

    The initialization shall occur in initializer list order, each initializer provided for a particular subobject overriding any previously listed initializer for the same subobject;151) all subobjects that are not initialized explicitly shall be initialized implicitly the same as objects that have static storage duration.

    Section 6.7.9 p10 states that

    If an object that has static or thread storage duration is not initialized explicitly, then...if it has arithmetic type, it is initialized to (positive or unsigned) zero;

提交回复
热议问题