Accessing struct member of pointer's address in C

前端 未结 4 1941
[愿得一人]
[愿得一人] 2021-01-07 08:35

I\'m reading this book, and I found this code snippet in Chapter 14.

struct kobject *cdev_get(struct cdev *p)
{
    struct module *owner = p->owner;
    s         


        
4条回答
  •  说谎
    说谎 (楼主)
    2021-01-07 08:42

    ->member has higher precedence than &.

    &p->kobj
    

    parses as

    &(p->kobj)
    

    i.e. it's taking the address of the kobj member of the struct pointed to by p.

提交回复
热议问题