Hi guys, I must admit I am sort of a newbie to C, so bear with me.
I have this pointer to a structure:
struct pool *dpa;
declared outside of main (making it global, I believe).
now I need to pass this pointer down 3 functions where the third function will need to mess with the data in the structure the pointer points to. Example:
/* call the first function and send the pointer to it */
First_Function(&dpa);
int First_Function(struct pool *pointer)
{
Second_Function(&pointer);
}
int Second_Function(struct pool *pointerTwo)
{
Third_Function(&pointerTwo);
}
int Third_Function(struct pool *pointerThree)
{
*pointerThree->somemember = somethingelse;
}
My question is, am I doing this right? Am I passing the pointer correctly? Am I accessing the structure correctly in the third function? The reason I am asking, is that it doesn't seem to be working this way.
I have seen things like instead of declaring struct pool *variable in the function parameters some people use struct pool **variable. I am not sure how to access the pointer to the struct to pass it on after that though...
Any help / clarification would be very much appreciated.
Thanks!
DanWiFi
I have this pointer to a structure:
struct pool *dpa;
declared outside of main (making it global, I believe).
now I need to pass this pointer down 3 functions where the third function will need to mess with the data in the structure the pointer points to. Example:
/* call the first function and send the pointer to it */
First_Function(&dpa);
int First_Function(struct pool *pointer)
{
Second_Function(&pointer);
}
int Second_Function(struct pool *pointerTwo)
{
Third_Function(&pointerTwo);
}
int Third_Function(struct pool *pointerThree)
{
*pointerThree->somemember = somethingelse;
}
My question is, am I doing this right? Am I passing the pointer correctly? Am I accessing the structure correctly in the third function? The reason I am asking, is that it doesn't seem to be working this way.
I have seen things like instead of declaring struct pool *variable in the function parameters some people use struct pool **variable. I am not sure how to access the pointer to the struct to pass it on after that though...
Any help / clarification would be very much appreciated.
Thanks!
DanWiFi