Assuming you know the exact size of each array and they are known at compile time, then the compare is just a memcmp()
with the correct size.
// you somehow know the size of the array
int a[WIDTH][HEIGHT];
int b[WIDTH][HEIGHT];
bool const equal(memcmp(a, b, sizeof(int) * WIDTH * HEIGHT) == 0);
// and if defined in the same scope, you can even use:
bool const equal(memcmp(a, b, sizeof(a)) == 0);
Note that my code assumes that both arrays (a and b) have the same size. You could test that first to make sure, with a throw or maybe an assert such as std::assert(sizeof(a) == sizeof(b)).
In case you don't know the size at compile-time sizeof
won't work since it's a compile-time operator, which means you'll have to pass the dimensions or consider using stl
.