Discussion
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.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development