A 2D array and a 1D array of same size are not same/similar although a 2D array can be represented as a 1D array (strictly speaking the behavior is undefined).
What I mean is: are they exchangeable?
It may depends on the situation.
A simple difference you can see by calling a function
void foo(int *p)
{
}
for the two cases. The first
can be passed to foo
either by passing &first[i][j]
, *first
or first[i]
(where i
and j
are int
type and representing the row and column index within array bound) while array second
can be passed as second
or &second[i]
.
You can not pass first
(unlike second
) and second[i]
(unlike first[i]
) to the foo
as an argument because they are incompatible with the expected parameter of foo
(which is of int *
).