Difficulty: Easy
Correct Answer: Error: in structure declaration
Explanation:
Introduction / Context:
This evaluates knowledge of self-referential structures. C allows a structure to have a pointer to itself but not an instance of itself as a member, because that would require infinite size.
Given Data / Assumptions:
Concept / Approach:
A structure’s size must be finite. If a structure contains a member that is an instance of the same type, computing the complete size becomes impossible (it would contain another full struct emp, which itself contains another full struct emp, ad infinitum). The valid idiom is to use a pointer: struct emp* e;.
Step-by-Step Solution:
Verification / Alternative check:
Replace struct emp e; with struct emp *e; and the declaration becomes valid. This pattern is widely used to build linked lists and trees.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming that since pointers are allowed, full nested instances are also allowed. Only pointers are permitted for self-reference inside the same structure.
Final Answer:
Error: in structure declaration
Discussion & Comments