Is this correct for assigning/dereferencing double ptr in struct?
Say I have the following:
Code:
struct node{
node **somenode;
node *othernode
}foo;
void somefunc(struct node *foo){
}
How would I dereference somenode? Also, how could I point it to othernode?
My compiler kept yielding warnings with some things I tried and so I've come to find that this works. But is it the correct way? Out putting addresses showed that somenode referenced what foo->othernode referenced instead of referencing foo->othernode itself.
Code:
void somefunc(struct node *foo){
foo->somenode = &*(foo->othernode);
}
Simply doing:
Code:
void somefunc(struct node *foo){
foo->somenode = &foo->othernode;
}
gives me warnings.