Let's say I have two structures,
struct ptr1
{
    struct ptr2 *ptrtoptr;
};
struct ptr2
{
    int name;
};
Main function looks like this:
int main()
{
    struct ptr1 *var1;
    struct ptr2 *var2;
    (code for manipulating structure element name);
    return 0;
}
How do a manipulate data of variable name via pointer var1? Let's say both pointers are already pointed at a certain address.
Is this correct? var1->(var2->name)=(some value) or (var1->var2)->name=(some value)? 
How do a manipulate data of variable name via pointer var1 ?
Using :
var1->ptrtoptr->name =  some_value ; // or (var1->ptrtoptr)->name
Neither of var1->(var2->name)=(some value) or (var1->var2)->name=(some value) make sense since var2 is not a member of ptr1, which can't be accessed using var1
Note: Also, be cautions about the operator associativity , operator -> has left to right associativity, therefore var1->(ptroptr->value) will not be same as var1->ptrtoptr->name 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With