how to fill array with function in c++ code example
Example: 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;
}