fill array function c++ code example
Example 1: how to fill array element in c++
fill(arr,arr+n,0)
Example 2: fill array c++
#include <iostream>
#include <array>
using namespace std;
main () {
array<int,6> myarray;
myarray.fill(5);
cout << "myarray contains:";
for (int& x : myarray) {
cout << ' ' << x;
}
cout << '\n';
//myarray contains: 5 5 5 5 5 5
return 0;
}