Hi,
I have the following variable declaration which looks like a 3d array or N matrixs KxK of floats
float (*table[N])[K];
I have to pass to a function only the first table.
How can I do it??
Thanks
Pass the first element table[0] which is the first table to the function.
What should the formal parameter be?? I tried
float **table
but doesn't work
What do you mean by formal parameter. In caller the called function takes arguments and in the called those arguments are known as parameters. If x calls y then...
/*
* table: an array[N] of pointers to an array[K] of floats
* table[0]: pointer to an array[K] of floats
*/
x() {y(table[0]);}
y(float (*pf)[K]) {}
ok, it works fine. thanks very much. Could you explain me why
y(float **pf){}
is not correct and in which cases i have to use it?
float **pf is not correct because it is a pointer to pointer to float i.e. dual level pointer while each element of the array table is a pointer to an array of floats...
x()
{
float x; /* x is a variable of type float */
float *pf; /* pf is a pointer to float */
float **ppf; /* ppf is a pointer to pointer to float */
pf = &x; /* pf now points to x */
ppf = &pf; /* ppf now points to pf */
}
ok, thanks very much.