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

后端 未结 3 992
伪装坚强ぢ
伪装坚强ぢ 2021-02-11 23:38

I have a struct str *s;

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

3条回答
  •  北荒
    北荒 (楼主)
    2021-02-12 00:12

    Yes, because the pointer dereference operator -> has higher precedence than the address operator &.

    • C operator precedence

提交回复
热议问题