title: Accessing struct member of pointer's address in C
body: <p>I'm reading <a href="https://static.lwn.net/images/pdf/LDD3/ch14.pdf" rel="nofollow">this book</a>, and I found this code snippet in Chapter 14.</p>
  
  <pre><code>struct kobject *cdev_get(struct cdev *p)
  {
      struct module *owner = p-&gt;owner;
      struct kobject *kobj;
      if (owner &amp;&amp; !try_module_get(owner))
          return NULL;
      kobj = kobject_get(&amp;p-&gt;kobj);
      if (!kobj)
          module_put(owner);
      return kobj;
  }
  </code></pre>
  
  <p>I understand that this dereferences p, a cdev pointer then accesses its owner member</p>
  
  <pre><code>p-&gt;owner // (*p).owner
  </code></pre>
  
  <p>However, how does this work? It seems like it dereferences the memory address of a cdev pointer then access the kobj member of the pointer itself?</p>
  
  <pre><code>&amp;p-&gt;kobj // (*(&amp;p)).kobj
  </code></pre>
  
  <p>I thought pointers weren't much more than memory addresses so I don't understand how they can have members. And if it was trying to access a member of the pointer itself, why not just do <code>p.kobj</code>?</p>