Difficulty: Medium
Correct Answer: stdio.h and stddef.h
Explanation:
Introduction / Context:
NULL is the canonical macro used to denote a null pointer constant in C. Many standard headers include its definition so that programmers can use NULL without memorizing which specific header introduced it in a particular translation unit.
Given Data / Assumptions:
Concept / Approach:
The C standard specifies that several headers define NULL, including
Step-by-Step Solution:
Identify headers guaranteed to define NULL.Confirm that both stddef.h and stdio.h are among them.Select the option that lists both together.
Verification / Alternative check:
Compile small files that include only stddef.h or only stdio.h and use NULL in a declaration; both compile successfully on conforming implementations.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing NULL (a null pointer constant) with 0 or with the C++ nullptr keyword; assuming only one header provides NULL.
Final Answer:
stdio.h and stddef.h.
Discussion & Comments