"Joe Pfeiffer" <> wrote in message
news:...
> "BartC" <> writes:
>> I don't know about the standard. But some experimentation shows only
>> the first element is set. The rest seem to be zeros.
>
> Well, yes -- if you specify any at all, the ones you specify are set to
> whatever you want. The others are all set to 0.
>
>> If you're only interested in zeros anyway, then it doesn't matter.
>
> It matters, since otherwise the contents of the array are effectively
> random.
I meant that, if element 0 *was* initialised to zero, the other elements are
coincidentally set to zero as well.
This won't work for a value other than zero, as it wouldn't be propagated
into the remaining elements as seemed (to me) to be implied if you didn't
read the other replies carefully:
int a[5]={0}; (0,0,0,0,0) as expected
int a[5]={1}; (1,0,0,0,0) not (1,1,1,1,1) as might be assumed.
--
Bartc
|