This may depend on how the matrix
function was allocated or passed.
int A[10][15];
It uses a continuous block of memory. To access elements without using array notation, use:
A +(i*15)+j // user694733 showed this is wrong
((int *)A)+(i*15)+j // this is horribly ugly but is correct
15, 15 . .
:
int *A[10];
A
- 10 int. , malloc
, :
*(A+i) + j;
A
, i
- , j
.
- EDIT -
:
int foo(int *p)
int. , n- . , .
n- , , .
int foo3(int *m, int dim2, int dim3, int i, int j, int k)
{
int *cell = m + i*dim3*dim2 + j*dim2 + k;
return *cell;
}