Difficulty: Medium
Correct Answer: DRAVID
Explanation:
Introduction / Context:
This question explores structure assignment semantics and pointer aliasing. It uses strupr on the copied structure’s char pointer under Turbo C (DOS), a historical environment where string literals were often placed in writable segments.
Given Data / Assumptions:
Concept / Approach:
Structure assignment copies pointer values, not cloned strings. After assignment, e1.n and e2.n alias the same storage. Calling strupr(e2.n) converts the characters to uppercase in that single shared storage. Therefore printing e1.n shows the uppercased content.
Step-by-Step Solution:
Verification / Alternative check:
On systems where string literals are read-only, modifying them is undefined behavior and may crash. The question pins Turbo C under DOS, where this commonly appears to work and produces DRAVID.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming deep copy of pointed-to data during structure assignment; in C, only the pointer value is copied unless explicitly duplicating the string buffer.
Final Answer:
DRAVID
Discussion & Comments