What are default values for arrays like this:
char c[20];
?
BTW, Are there any?
If declared at namespace scope then c
will have static storage scope and will be zero-initialized so every element of c will have value '\0'
.
If declared in a function then c
will not be initialized. The initial value of the elements of c
will be indeterminate.
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 :))
Undefined or in less technical language - random.
Your compiler (at least in debug mode) may set it to a particular value for testing.
And of course from a strict Copenhagen interpretation of quantum theory the value it does have is both indeterminate (used in it's correct sense) until you collapse the wavefunction by measuring it.
This in NOT 'undefined'. It is 'indeterminate'. The values are simply are not known.