Initialize multidimensional array with zeros

前端 未结 3 1787
时光取名叫无心
时光取名叫无心 2021-01-03 10:15

In C++ you can initialize a one dimensional array with 0 with a code like this:

int myarray[100] = {0};

Is there a similar way for multidim

3条回答
  •  花落未央
    2021-01-03 10:46

    use vector instead of array it will give you more flexibility in declaration and in any other operation

    vector > myarray(rows,vector(columns, initial_value));
    

    you can access them same as you access array,

    and if u still want to use array then use std::fill

提交回复
热议问题