I've been revising on my coding skills recently and then I made a program that outputs the contents of a multidimensional array. It is simple but when I experimented with the code this is what that happened:
int dv[3][3] {
{1,2,3},
{4,5,6},
{7,8,9}
};
for (auto col = dv; col != dv + 3; ++col) {
for (auto row = *dv; row != *col + 3; ++row) {
cout << *row << " ";
}
}
Output:
1 2 3 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9
Can anybody please tell me why is this happening?