Null pointer
what is 'null pointer' exactly in 'C' ...?
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Oct 22, 2013, 8:15 AM EDT
Abhishek JaiswalRank #126 · 17.5K reputationPosted Oct 22, 2013, 10:12 AM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 22, 2013, 11:50 AM EDT
In C, you're guaranteed that all variables and functions will always have a non-zero address. You can therefore be certain that a null pointer (i.e. a pointer with the value 0) can never point to a valid entity as I said earlier.
If you have a function which returns a pointer, you can therefore return a null pointer to indicate 'no result' or that some error occurred.
There is a constant NULL defined in the standard library which you can use to indicate a null pointer instead of the integer 0.
Suraj Binorkar122 reputationPosted Aug 6, 2016, 1:25 AM EDT