c - Assigning values to pointers? -


in dennis ritchie found this,

struct rect r , *rp = r; 

then these 4 expressions equivalent :

  1. r.pt1.x
  2. rp->pt1.x
  3. (r.pt1).x
  4. (rp->pt1).x

because operators associate left right.
shouldn't struct rect *rp = &r?

absolutely -- address operator required, otherwise compile-time error:

incompatible types when initializing type ‘struct rect *’ using type ‘struct rect’ 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

python - How to create a legend for 3D bar in matplotlib? -