2D Array as parameter

I want to create a function that accepts a 2D array as a parameter and modify/add the values to it, how would i be able to do so?
If the argument will be a statical array then you can define the function as

void f( int ( *a )[N], int m );

where N is constant ( number of columns) and m is number of rows.

Or you can declare the parameter as a reference to an array

void f( int ( &a )[M][N] );

where M and N are constants.

If the array is allocated dynamically then you can declare the function as

void f( int **a, int m, int n );
Last edited on
Topic archived. No new replies allowed.