According to the C standard (SO link 1 and link 2) we cannot access an element of a row using out-of-bounds index:
int x[10][10] = ...; // initialize x
int q = x[0][10]; // This is an out-of-bounds access
Then is it valid to initialize the array using the following loop?
int *p = &x[0][0];
for (int i = 0; i < 100; ++i)
p[i] = 0;
If this is not valid, then is it valid to initialize x
using memset(&x[0][0], 0, sizeof(x))
?
int *p = &x[0][0];
memset(p, 0, sizeof(x))?
edit: I wonder whether the answers are different in C++ as well..! :)