Interview Questions

I am confused. I just can't understand all this null pointer stuff

C Interview Questions and Answers


(Continued from previous question...)

I am confused. I just can't understand all this null pointer stuff

Here are two simple rules you can follow:
1. When you want a null pointer constant in source code, use ``0'' or ``NULL''.
2. If the usage of ``0'' or ``NULL'' is an argument in a function call, cast it to the pointer type expected by the function being called.
The rest of the discussion has to do with other people's misunderstandings, with the internal representation of null pointers (which you shouldn't need to know), and with the complexities of function prototypes. (Taking those complexities into account, we find that rule 2 is conservative .

(Continued on next question...)

Other Interview Questions