thanks for the reply :)
please, could you tell me why should I change matrix into an integer double pointer reference?
what happens in it is a reference in this case?
So the point is that in the function I wasn't operating on the matrix and I solve it by passing the memory address of the double integer pointer...right?
But in this case isn't enough to pass the address of the matrix? like this:
1 2 3
...
allocateMatrix(&mat, nrow, ncol);
and change the function into this:
1 2 3 4 5 6 7 8
void allocateMatrix(int ***matrix, int nrow, int ncol)
{
int i;
*matrix = newint*[nrow];
for (i=0; i<nrow; i++)
*matrix[i] = newint[ncol];
}
in this way it might work on the mat memory address and so declare a dynamical matrix "connected" to matrix itself.
Yes, this works too. In fact, it's the same as the reference approach (your compiler would generate exactly the same code), except it's somewhat less readable. References are usually implemented as pointers internally. Think of a reference as a pointer that automatically dereferences itself every time it's used.