Initialization of arrays in C

前端 未结 7 1050
难免孤独
难免孤独 2021-01-21 23:57

In C, I have read that half-initialized arrays will be filled with zeros for the rest of the elements (irrespective of integer or char arrays).

E.g.:

in         


        
7条回答
  •  再見小時候
    2021-01-22 00:26

    This is according to the C standard, and any compiler following the C standard must do this. However, not all compilers are 100% standard compliant, and you'll have to check if yours does this or not, if you're unsure.

提交回复
热议问题