W
whisper
Hi: there is an issue that confuses me and the FAQ did not clarify it
for me.
(Sorry I am just learning!)
Let say I define a multidimensional array in my main routine as
follows:
int arr[2][3]={{0,1,2}, {3,4,2}};
and I pass the array as a parameter to a function declared by:
int getsum(int arr[][], int numrows, int numcols)
by calling getsum(arr,2,3) (getsum tries to sum up all the elements).
I know that this is illegal, but I don't quite understand why.
When arr is created (at compile time), we know exactly what its row
width
and column width are. So why do we have to pass that information to
getsum ?
Thanks
for me.
(Sorry I am just learning!)
Let say I define a multidimensional array in my main routine as
follows:
int arr[2][3]={{0,1,2}, {3,4,2}};
and I pass the array as a parameter to a function declared by:
int getsum(int arr[][], int numrows, int numcols)
by calling getsum(arr,2,3) (getsum tries to sum up all the elements).
I know that this is illegal, but I don't quite understand why.
When arr is created (at compile time), we know exactly what its row
width
and column width are. So why do we have to pass that information to
getsum ?
Thanks