I have been trying to solve this problem the whole day:
How do I pass a double array to a function?
Here is an example:
int matrix[5][2] = { {1,2}, {3,4}, {5,6}, {7,8}, {9,10} };
And I wish to pass this matrix to function named eval_matrix,
void eval_matrix(int ?) {
...
}
I can’t figure out what should be in place of ?
Can anyone help me with this problem?
I know that an array can be passed just as a pointer, but what about a double array (or triple array?)
Thanks, Boda Cydo.
To be usable as an array the compiler has to know the inner stride of the array, so it’s either:
or:
or just:
In any case it’s syntactic sugar – the array is decayed to a pointer.
In first two cases you can reference array elements as usual
m[i][j], but will have to offset manually in the third case asp[i*id + j].