Dear C experts,

First and foremost, please let me thank you for all your help in this forum. You are making my coding life much, much more pleasant :-)

Now, to the point. I need to create a struct in which member points to another (global) variable. As I am to pass this struct to functions, and pointers to pointers make me nervous, I thought of checking with the experts first.

Let me explain myself with a silly example. I know that if I define a function like this:

Code:
void myfunc(double *varvalue)
{
    *varvalue = somevalue;
}
and then I call it as

Code:
myfunc(&othervariable);
then the global variable "othervariable" will get the value "somevalue". (I hope I am correct here).

Well, now I need to do that with structs. My guess (which could be totally wrong) is that I should do the following:

Code:
typedef struct _sType 
{
    double *value
} sType;

sType mystruct;
Then, I would initialize it like this?

from main:
Code:
*mystruct.value = &othervariable
from a function:
Code:
void initfunc(sType *s)
{
    *s->value = &othervariable
}

Now, to update the value of "othervariable" should I do this?

from main:
Code:
*mystruct.value = somevalue;
and from within functions:
Code:
void myfunc(sType *s)
{
    *s->value = somevalue
}
Please let me now whether any (or all) of my assumptions are wrong.

Thanks so much, as usual, for your help

mc61