Using arrow -> and dot . operators together in C

后端 未结 5 1430
灰色年华
灰色年华 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:24

    . is for accessing the members of a struct (or union) e.g.

    struct S {
    int x;
    }
    
    S test;
    test.x;
    

    -> is a shorter way to write (*pointer_to_struct).struct_member

提交回复
热议问题