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

Discussion

Is the NULL pointer same as an uninitialised pointer?

  • A.Yes
  • B.No

Answer: B

Correct answer: No

A null pointer holds a defined value that compares unequal to any valid address, so it can be tested with if (p) and used as a sentinel. An uninitialised pointer holds whatever happened to be in memory, so it cannot be tested meaningfully and dereferencing it is undefined. Confusing the two is why uninitialised pointers should always be set to NULL explicitly.

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

Post your comment

Please log in or register to post a comment.