Plz explain how to pass 2D array to function

Bhaiya can you plz explain how you passed the 2d array using syntax a[][1000] ?

Hi @diskordiciti369
there are various methods to pass 2d array as function parameters

this is one way
a[][1000]
so while passing the 2Darray it is compulsory to pass the last value of matrix
so since this matrix is 2*2 matrix
so the 2nd paramter ie no of columns needs to be compulsorily sent
u may not want to send no of rows

u could have sent a[ROWS][COLUMNS]

the no of columns needs to be same as that defined in the calling function

I am getting this error:

cannot convert β€˜int ()[n]’ to β€˜int ()[100]’ for argument β€˜1’ to β€˜void spiral_print(int (*)[100], int, int)’ spiral_print(a,m,n);

u cannot pass a[][n]
u need to pass
a[][100]

Got it. Thank you so much :slight_smile:

1 Like