Using std::fill
will work, but you have to resort to using reinterpret_cast<>
, which is often considered bad form:
#include <algorithm>
int a[5][5];
std::fill(reinterpret_cast<int*>(a),
reinterpret_cast<int*>(a)+(5*5),
1);
Alternatively, you could take the address of the first element, which is likewise clunky:
std::fill(&a[0][0],&a[0][0]+(5*5),1);