当初始化字符数组,是剩余空间零填充或初始化?

当初始化字符数组,是剩余空间零填充或初始化?

问题描述:

由于

char foo[1024] = "bar";

这将初始化富遏制'B','A','R',0。在剩余1020个字符初始化为零,或者未初始化?

This will initialize foo to contain 'b','a','r',0 . Is the remaining 1020 characters zero initialized, or uninitialized ?

我觉得上面是一样的`字符富[1024] = {'B','A','R','\\ 0'};并且与骨料的初始化,没有提到任何成员被初始化为零?

I'd think the above is the same as `char foo[1024] = {'b','a','r','\0'} ; and as with initializing of aggregates, any member not mentioned is initialized to zero ?

如果数组/总以某种​​方式初始化,其余未指定的条目被归零,是

If an array/aggregate is initialized somehow[edit: by use of a static initializer], the remaining unspecified entries are zeroed, yes.