When you declare an array as a function parameter:
int X3(int m[3][3]
{
...
}
You are telling the compiler that
X3
accepts a single parameter, which is a 3 x 4=3 array of integers.
When you call a function with a parameter like this:
X3(m[3][3]);
You are
dereferencing the array to a single element of that array - which actually lies outside the bound of the array itself:
int m[3][3];
because in C++, array indexes start at zero.
The dereference is the same as assigning a variable:
int x = m[0][[0];
Puts the value in the first element of the first row of the array
m
into
x
There are numerous problems with that code that you haven' noticed yet, including (but not limited to):
*
X3
does not retrun a value.
* if you returned the "new array"
x
from
X3
you would have a dangling reference, and your code would start to behave very badly - you can't return stack based items and expect it to work properly!
* why are you looping and using constant values in
X3
?
That code doesn't look "Planned" - it looks like you quickly scanned teh take and leapt into code without thinking about what you are expected to do - and it shows as poor code that really isn't worth saving. Back that up somewhere, and start again from scratch - read the assignment carefully, and think about how to solve it for five or ten minutes before you even start l=thinking about code. It'll save you loads of time in the long run!