how to fill c++ array code example
Example 1: 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;
}
Example 2: how to fill array element in c++
fill(arr,arr+n,0)