I have seen several C code examples which utilise the (*p)->some_var way of working with pointers (using parens around the pointer).
My question is, is there any functional difference between the two methods of working with C pointers, and if so, how did this difference come about?
Those do not do the same thing at all. Compare:
(*p)->some_var // aka (*(*p)).some_var
This means "p is a pointer, which we dereference, then dereference again to access a field."
*p->some_var // aka *((*p).some_var)
This means "p is a pointer, which we dereference to access a field, which is a pointer which we dereference."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With