Remember that data[4][2] is the 3rd element in the 5th array.
Code:
// Try to visualise the 2D array indexes something like this,
0: [0] [1] [2]
1: [0] [1] [2]
2: [0] [1] [2]
3: [0] [1] [2]
4: [0] [1] [2]
Also, remember that "data[]" is an array of pointers (to arrays). Hence, the function can only deduce how many arrays there are (more accurately, it checks the number of elements of data[]). So, it cannot deduce the size of each individual "sub" array (For lack of a better term) - so you must specify that explicitly.
I believe you may have misunderstood his instructions, but the closest to what you described would be something like:
Code:
void output(int arr2D[][3], int a) // some number of arrays, as defined by 'a', of size 3
{
for (int i=0; i!=a; ++i)
{
for (int j=0; j!=3; ++j)
cout << arr2D[i][j] << " ";
cout << endl;
}
}
Personally, I would use STL vectors to do this instead (since vectors keep track of dimensions, life is made much easier).. as you can see, this sort of method is messy.
But if you've been told not to use containers, and have to use arrays, then a better way to do this would be to create a Matrix class, as a wrapper for your 2D array (in other words, make your own container).