Are parenthesis needed to get the address of a struct member from a pointer to the struct as in “&(s->var)” vs “&s->var”?

后端 未结 2 2137
难免孤独
难免孤独 2021-02-11 23:18

I have a struct str *s;

Let var be a variable in s. Is &s->var equal to &(s->var)?

2条回答
  •  时光说笑
    2021-02-11 23:53

    Yes.

    (-> is higher precedence than &. See http://cppreference.com/wiki/language/operator_precedence)

提交回复
热议问题