Machine-translated by Google. Questions are authored in English.
Top

Discussion

In which header file is the NULL macro defined?

  • A.stdio.h
  • B.stddef.h
  • C.stdio.h and stddef.h
  • D.math.h

Answer: C

Correct answer: stdio.h and stddef.h

NULL is defined in several headers, among them stdio.h and stddef.h, and also stdlib.h, string.h, time.h and others.

The duplication is deliberate. A programmer using any of those libraries is likely to need NULL, and the standard permits a macro to be defined identically in more than one header, so each defines it rather than forcing an extra include. stddef.h is the canonical home, holding it alongside size_t and ptrdiff_t.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.