Given a user-defined type A, and a pointer A* a, what is the difference between *a and a[0]?
(Though *(a+0)/a[0] are defined to be equivalent, the same is not the case for *a/a[0], where a subtle difference may cause a compilation error in certain circumstances.)
If
Ais an incomplete type,*aworks, buta[0]does not, in this example:That’s because
a[0]is equivalent to*(a+0), but you cannot add something to a pointer to an object of incomplete type (not even zero), because pointer arithmetic requires the size to be known.