Interview Questions

But wouldnt it be better to use NULL

C Interview Questions and Answers


(Continued from previous question...)

But wouldnt it be better to use NULL

Q: But wouldn't it be better to use NULL (rather than 0), in case the value of NULL changes, perhaps on a machine with nonzero internal null pointers?

A: No. (Using NULL may be preferable, but not for this reason.) Although symbolic constants are often used in place of numbers because the numbers might change, this is not the reason that NULL is used in place of 0. Once again, the language guarantees that source-code 0's (in pointer contexts) generate null pointers. NULL is used only as a stylistic convention.

(Continued on next question...)

Other Interview Questions