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!