Declaring array with an initial value in C++
If you declare an array like
int myArr[10] = {};
It will initiate your array with all values
int myArr[10] = {-1};
This will initiate your array with first element -1 and the rest.
If you want to fill your array with specific length and number, you should use native std::fill or std::fill_n functions. For more information about those functions and use please visit C++ Reference.
Comments