While writing a rather simple code for an exercise i was assigned, I run into this problem. The exercise asks me to create a function (what it does it's not important, but it loops through each element of the matrix to do something) getting as parameters a 2D array (NxM) and a double (which is used in the function). The function so looks something like this:
int function(int (*myarray)[M], double y){}
Now if I'm not missing anything, this is not enough because I can't loop through the elements without using the value N as range. Am I right? If there is no way to use the number of rows inside this function without passing it as a parameter, it means that the exercise took for granted that passing the matrix meant also passing N (rows) as a parameter.
(I thought about using sizeof to get the number of rows somehow, but sizeof(myarray) inside function(){} doesn't work as expected. What is the difference between myarray inside this function and the original myarray I declared in main()?)
myarray is declared as int myarray[N][M];
and then initialized with a loop which contains myarray[i][j] = rand()%(max-min+1)+min;
. I don't think this is too relevant to the problem but I include it to explain it is automatically allocated.
I already checked some similar discussions like thisand this but since everyone gives the dimension as parameter I didn't find an answer yet.