Pointer to a pointer to a pointer .. to a struct

Hello. So I have something *like* this:
1
2
3
4
5
6
struct node
{
    // magic stuff
    type t;
    node *next;
} var;


I tried to access the next node like:
1
2
(*var).next.t
(*var).(*next).t

and few more (things ? syntaxes ?).

I know that (*var).t works well, but I am wondering why my "solutions" aren't working. Maybe is another syntax ?

P.S.: I know about "->" and I use it, but I like to try new things and I hope you can help me (are the var->next->t or (*var).next->t the only options ?)
Last edited on
Unless you want to write your own method then yes, -> and . are your only choices. I recommend using -> since it's more common.
Correct way to write this without using pointer member selection operator (dereference only) is to write:

1
2
3
4
5
6
(*((*var).next)).t

(*var) //Transform pointer into reference
(*var).next //Select next member
(*(*var).next) //Transform next pointer to reference
(*((*var).next)).t //Select t member 
Topic archived. No new replies allowed.