I am working on some C code.
There is a function like this;
void Get(double x_la[],
doubl开发者_JS百科e y_la[],
double z_la[])
in the function body, for some other reasons I create;
double (*la)[3];
As far as I understood, x_la, y_la and z_la are pointers of the type double.
I need to "connect" the pointers involved in "la" wiht the previous ones, so I thought trying;
la[0]=x_la;
la[1]=y_la;
la[2]=z_la;
but during compilation with gnu compiler I get the error;
error: incompatible types in assignment of 'double*' to 'double [3]'
What I am doing wrong? Otherwise, how could do it well?
Thanks
P.D. Is it exactly the same to declare
double y_la[]
or
double *y_la
?
You want double *la[3];
.
As you have it, la
isn't a pointer to double but a single pointer to an array of three things, and so each la[i]
is still a pointer to something other than a double, and doubly problematic because you really only have one of them.
As to the second question, those are only the same in a parameter list, and even then only in an old-style declaration. Once you type in a prototype, then type conformance is governed by a more precise set of rules.
精彩评论