Using arrow -> and dot . operators together in C

后端 未结 5 1429
灰色年华
灰色年华 2021-02-01 07:51

I was under the impression that it was possible to access data from a sub-node of a linked list or similar structure by using the arrow and dot operators together like so:

5条回答
  •  醉话见心
    2021-02-01 08:19

    sample->left gives a struct a*, not a struct a, so we're dealing with pointers. So you still have to use ->.

    You can, however, use sample->left->num.

提交回复
热议问题