If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable?
Answer: D
Correct answer: ->
The arrow operator accesses a member through a pointer to a structure: p->member is by definition equivalent to (*p).member.
The parentheses in that expansion are essential, which is why the shorthand exists - . binds more tightly than *, so *p.member would be parsed as *(p.member) and rejected. The dot operator is for a structure object itself, not for a pointer to one.
Please log in or register to report this question.