When initializing a char array, is the remaining space zero filled or uninitialized?

前端 未结 2 1538
眼角桃花
眼角桃花 2021-01-18 01:44

Given

char foo[1024] = \"bar\";

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

2条回答
  •  [愿得一人]
    2021-01-18 02:36

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

提交回复
热议问题