ACtE03 · Chapter 3Programming & Applications🏛️ Past Licensure QuestionID: 6cae8a7c
Given a pointer p to a structure containing a nested structure member z, which in turn contains a field e, how is e correctly accessed?
Given a pointer p to a structure containing a nested structure member z, which in turn contains a field e, how is e correctly accessed?
Multiple Choice Options
- A✓ Correct Option
p->z.e
- B
p.z.e
- C
p->z->e
- D
p.z->e
Detailed Technical Solution & Explanation
Since p is a pointer to the outer structure, the arrow operator -> is required to dereference and select member z (p->z). Since z is a nested structure object (not a pointer), the dot operator . is used to select e from z (p->z.e).
Option Analysis:
•
Option A (p->z.e): Correct. Uses
-> for pointer p and . for structure instance z.•
Option B (p.z.e): Invalid syntax because
p is a pointer, not a direct structure instance.•
Option C (p->z->e): Invalid unless
z were also a pointer.•
Option D (p.z->e): Invalid;
p cannot use dot notation.Reference: Demo2 · Set 2NEC Licensure Syllabus