# Thread: hello all quick pointers question

1. ## hello all quick pointers question

i had to write this func. on an assignment

Code:
```int checkMat(int**mat , int rows)
{
int i,j;
int sum=0;    // will be the sum of the first - the sum of the second if sum=0 then they're equal
for (i=0;i<rows;i++)
for(j=0;j<rows;j++)
sum = sum+mat[i][j]-mat[rows-i][rows-j];
if (sum=0) return 1;
return 0;

}```
now i want to test it in the main so i did :
Code:
```	int arr[2][2]={{3,5},
{9,4}};
printf("%d",checkMat(arr[0],6));```
and it gives a "argument of type incompatible" what am i doing wrong in the main ?

i don't want to change the signature of the function
tnx all helpers !

2. Your function wants int **mat... you are handing it an array.

3. so i have to send it a 2d array pointer ? i can't send the array like in regulars arrays ?

4. ok i read it i understand why it doesn't work , so i tried to make a pointer to point to the 2d array like so:
Code:
```	int arr[2][2]={{4,6},{3,6}};
int **p ;
**p[2]=&arr[0][0];```
i tried other variations in order to make it work , any ideas on how to make a pointer point to the 2d array ?

5. Code:
```void foo ( int (*arr)[2] ) {
// do stuff with arr[x][y]
}
int main ( ) {
int arr[2][2]={{4,6},{3,6}};  // 2D array
int (*pa)[2] = arr;  // pointer to 2D array (or more accurately, pointer to the first row of the array)
foo( arr );  // call it
foo( pa );  // call it again
return 0;
}```

6. yea ok but my function signature is
Code:
`int checkMat(int**mat , int rows)`
so i can't do
Code:
`checkMat(arr)`

7. If this is a two-dimensional array, shouldn't you be passing both the row count and the column count to the function? Actually, I guess if it's square it doesn't really matter. I'm just really specific about that sort of stuff.

8. Well if you have int**, and you can't change it, then you can't pass a true 2D array to it without some additional code.

Say
Code:
```int arr[2][2]={{4,6},{3,6}};  // 2D array
int *pa[2] = { &arr[0][0], &arr[1][0] };
checkMat( pa, 2 );```

9. yea i forgot to say it was a square
ok it works now thanks a lot
can you just explain a little about what you did there ?
is it like an array of pointers ?

10. int (*pa)[2]
Pointer to an array.

int *pa[2]
Array of pointers.

11. oh i c , thanks a lot
it really cleared some issues for me