How to pass 2d array in a function

#include<bits/stdc++.h>
using namespace std;
int paths(int m,int n,int a,int b,int* arr[b])
{
if(m<0||n<0)
return 0;
if(m==0&&n==0)
return 1;
if(arr[m][n]==1)
return 0;
return paths(m-1,n,a,b,arr)+paths(m,n-1,a,b,arr);
}
main()
{
int m,n,p;
cin>>m;
cin>>n;
cin>>p;
int arr[m][n];
for(int i=0;i<p;i++){
int a,b;
cin>>a>>b;
arr[a][b]=1;
}
cout<<paths(m-1,n-1,m,n,arr);
}

What is the problem in above code as it is not compiling?

When you are passing the array , the function doesn’t knows what is b for allocating the memory for array .
Take the size for column greater than the maximum possible value like int a[m][100000] , and then pass it to function . Your function will be like
int paths(int m,int n,int a,int b,int a[][100000])
{

}

I couldn’t understand the syntax for passing an array to a function -

  • Why do we use a * while declaring the array as argument in the function ? Are we using pointers here ?

  • For 2-D Array, which among number of rows or columns do we need to clearly specify while declaring the array as argument to function ?

  • Extrapolating the above point, how is the syntax while declaring an N-Dimensional Array as an argument to a function ? Which all dimension sizes need to be specified ?

  • we declare a pointer variable which shows that it will store an address… as arrays are passed by address, therefore the pointer variable in arguments will store the address of first element of the array.

  • you need to clearly specify the no. of columns.

  • you can declare the value of dimensions globally and then you can pass them in argument or you can use pointers.