xhungab wrote:
Hello,
If the function det_Z(), is of this type :
complexZ det_Z(double **A);
You haven't completely specified the type, since you haven't told us
what a complexZ is. But it is clear that det_Z is a function that takes
a pointer to pointer to double, and returns a complexZ. Whatever that is.
You also haven't told us what this function is supposed to do.
Can I write :
do
{
r_mZ(A,999.);
printf(".");
}while(!det_Z(A).r);
How are we to know, without the declaration of r_mZ, A, and complexZ?
You haven't told us what type A is. It should be a pointer to pointer to
double, or perhaps pointer to void, if the above code is correct.
You haven't told us what type complexZ is. It should be a struct
containing at least one member, named r, of an arithmetic or pointer type.
You haven't told us what the type of r_mZ is. It should be a function
taking two arguments: (1) a pointer to pointer to double and (2) a
double. It should probably return void, but it may return something else
if you ignored its return value above.
instead of
complexZ z;
do
{
r_mZ(A,999.);
z = det_Z(A);
printf(".");
}while(!z.r);
The code above is equivalent to the previous code. The exception is that
the value of z is still available after the loop in case you still
wanted to use it.
I suppose the question should have been:
"Can I use the struct member access operator (.) directly
on the return value of a function?"
struct foo {int a;};
struct foo bar(void)
{
return (struct foo){0};
}
int main(void)
{
return bar().a;
}
The answer is, yes, you can.
--
Simon.