Multiple choice

P is a pointer to the structure. A member “mem” of that structure is referenced by

  1. *p.mem

  2. (*p).mem

  3. *(p.mem)

  4. None of these

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To access a structure member through a pointer, you must dereference the pointer first before applying the dot operator. (*p).mem correctly dereferences p to get the structure, then accesses mem. The shorthand p->mem is equivalent and more commonly used. *p.mem would try to dereference a non-existent p.mem, and *(p.mem) is invalid.