Any shortcut to initialize all array elements to zero?

后端 未结 14 2787
北恋
北恋 2020-11-28 18:12

In C/C++ I used to do

int arr[10] = {0};

...to initialize all my array elements to 0.

Is there a similar shortcut in

14条回答
  •  没有蜡笔的小新
    2020-11-28 18:36

    Yes, int values in an array are initialized to zero. But you are not guaranteed this. Oracle documentation states that this is a bad coding practice.

提交回复
热议问题