
Structure containing pointer problem
Hi, I've got this problem. I'm not sure whether it's my compiler and my
programming, so if you could help that would be great!
My program layout is like this
typedef struct{
double **a;
double **b;
Quote:
} mystruct;
void myfunction(double x,double y,double *result1,double *result2)
{
stuff
Quote:
}
void usemyfunction(double x,double y,mystruct *new_struct)
{
allcate memory to (*new_struct).a and (*new_struct).b
stuff
myfunction(x,y,&((*new_struct).a[i][j]),&((*new_struct).b[i][j]));
stuff
Quote:
}
My problem is the following;
(i) after allocating some space to the pointers in mystruct
(ii) how do I pass in the address of one of the elements of a field of that
struct to myfunction(), like that above in usemyfunction()
when I do this the values of result1 and result2 (ie... thier locations) are
0, even though (*new_struct).a != 0?
I've also tried
&(new_struct->psi[i][j])
but that also comes through as a 0.
how do I pass the address of an element of an array of double pointers from
within a structure pointer??
--
Hybrid Physicist/Mathematician/Computer Scientist
University of Waikato
New Zealand (PRO "New ZEE-Land")
(In)famous last words : "Demi-Lich? That's only half a Lich isn't it??"