How do i pass a 2d array as parameter without use of any pointers

this code shows error

void printArray(int arr[][],int m.int n){

for(int i = 0;i < m;i++){

for(int j = 0;j < n;j++){

cout << arr[i][j];

}

}

}

int main(){

cin >> m >> n;

int arr[m][n];

for (int i = 0; i < m; ++i) {

for (int j = 0; j < n; ++j) {

cin >> arr[i][j];

}

}

printArray(arr,m,n);

return 0;

}

Hi,
i can suggest u 3 ways

1_ When both dimensions are available globally (either as a macro or as a global constant).
const int M = 3;
const int N = 3;

void print(int arr[M][N])
{ } used when the problem statement gives u fixed size 2d array which happens to be very rare
2.When only second dimension is available globally (either as a macro or as a global constant)
make it some big value ( generally the maximum defined in the constraint )
const int N = 3;

void print(int arr[][N], int m)
{ } // following the logic that only the no of column is a must to be passed in case of 2 d array

  1. use vector<vector> vec approach ( i really feel this to be convinient)

I haven’t studied vectors yet and the other two methods have failed , I have already tried, can you send me a link of a simple program that passes 2d array without pointers and works

I tried the methods in this link before asking doubt, they work in C but not in C++, can you send me a small program if it works solving my problem

what if I have to take array size input from user

then define M as some maximum value which is the upper bound limit for the input by user
for ex:
if constraints are given size of matrix will be at max 500 X 500
declare M as 501
anything greater than maximum size of row and column