NULL Macro

What is NULL Macro? What is the difference between a NULL Pointer and a NULL macro?

Questions by neelamsreedevi

Showing Answers 1 - 3 of 3 Answers

From the C language standard, section 6.3.2.3, paragraph 3:
--------
An integer constant expression with the value 0, or such an expression cast to void *, is called a null pointer constant. 55)  If a null pointer constant is converted to a pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function.
...
55) The macro NULL is defined in <stddef.h> (and other headers) as a null pointer constant; see 7.17.
--------

IOW, a null pointer constant such as the NULL macro will always evaluate to 0; a null pointer value may or may not evaluate to 0.  It's up to the compiler to map the two, so that expressions like "if (!ptr)" and "if (ptr == NULL)" work. 

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions