Are the members of a global structure initialized to zero by default in C?

后端 未结 5 1781
星月不相逢
星月不相逢 2020-12-04 22:21

Are the members of a global or static structure in C guaranteed to be automatically initialized to zero, in the same way that uninitialized global or static variables are?

5条回答
  •  难免孤独
    2020-12-04 22:44

    A struct is no different in this manner than a normal static C variable. The memory reserved for that struct is completely initialized to 0 if it's a static.

提交回复
热议问题