Default values in array

前端 未结 4 1518
逝去的感伤
逝去的感伤 2021-01-02 05:39

What are default values for arrays like this:

char c[20];

?

BTW, Are there any?

4条回答
  •  悲哀的现实
    2021-01-02 06:29

    As it is already said - values are indeterminate. But, I have to mention that if your array is static or global, the values are initialized to their default values, which usually means they will be initialized to zeros (or '\0' in the case of array of chars).

    EDIT: As Noah Roberts suggested, the term "indeterminate" is probably more appropriate than "undefined" (strictly mathematically speaking) - so suggestion is accepted and I've changed the term to "indeterminate". But majority of us are engineers or programmers here, not mathematicians (I suppose) and similar omissions should be forgiven :))

提交回复
热议问题