LearnFrenzy
Sign in Take a free test

Declarations and Initializations · Declarations MCQ · Question 12

What is nullptr in C23? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 12 Back to Exercise

Which statement about C23's nullptr is true?

  • A It is a macro for 0
  • B It is a null pointer constant with its own type, nullptr_t, that converts to any pointer type Correct
  • C It is an integer constant
  • D It replaces NULL in all older code automatically
Correct Answer: Option B

NULL may be defined as 0 or ((void*)0), which causes surprises with variadic functions and _Generic. nullptr always has pointer meaning; int *p = nullptr; declares a null pointer.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links