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:
and then I call it as
void myfunc(double *varvalue)
*varvalue = somevalue;
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:
Then, I would initialize it like this?
typedef struct _sType
from a function:
*mystruct.value = &othervariable
void initfunc(sType *s)
*s->value = &othervariable
Now, to update the value of "othervariable" should I do this?
and from within functions:
*mystruct.value = somevalue;
Please let me now whether any (or all) of my assumptions are wrong.
void myfunc(sType *s)
*s->value = somevalue
Thanks so much, as usual, for your help