LearnFrenzy
Sign in Take a free test

Decision Making · Decision Making MCQ · Question 8

if (p) when p is a pointer – what does it test? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

For a pointer p, what does if (p) test?

  • A Whether *p is non-zero
  • B Whether p is not a null pointer Correct
  • C Whether p points to a string
  • D It is a compile error
Correct Answer: Option B

A pointer used as a condition is compared with the null pointer: if (p) means if (p != NULL). It says nothing about the value p points to.

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