How to pass a 2-dimensional array to a function?

H!I
There is a 2d array (foe example int** Table (allocated))
how can we pass it to a function?

(it is not a 1-DIMENSION ARRAY (for example Table = new int [row*column])

it is how we can use it as Table [I] [j] ;
Just treat it as an array of arrays. Some textbooks call them ragged arrays.
you mean something like this?

function declaration :
int CheckTable (int ** Table)

then we pass it like this :
ChekcTable (Table)


I Dd it but the VS errored.
Those 2 lines of code as shown would result in several errors. Both lines should end in ; and ChekcTable is misspelled.
Also, you haven't said what the errors are.
You aren't giving us enough to see what's wrong.
The code you posted (if it had no syntax errors) should work though.
Last edited on
int** Table is not a two-dimensional array. It is a pointer to pointer. That to pass it to a function and use the syntax of accessing elements as of two-dimensional array you should also declare two additional parameters in the function one of which will specify the first dimension and the other will specify the second dimension. For example

void f( int **Table, int n, int m );
Topic archived. No new replies allowed.