C++ array initialization

前端 未结 4 1937
Happy的楠姐
Happy的楠姐 2020-12-02 06:26

is this form of intializing an array to all 0s

char myarray[ARRAY_SIZE] = {0} supported by all compilers? ,

if so, is there similar syntax

4条回答
  •  暖寄归人
    2020-12-02 06:54

    Note that the '=' is optional in C++11 universal initialization syntax, and it is generally considered better style to write :

    char myarray[ARRAY_SIZE] {0}
    

提交回复
热议问题