

This is one of the reasons why the usage of NULL is preferred because it makes it explicit in the code that the programmer is using a null pointer, not integer 0. Please note that 0 in the above C statement is used in pointer-context and it’s different from 0 as integer. It means that the following is also perfectly legal as per standard: But, C standard is saying that 0 is also a null pointer constant. Though the actual C11 standard can be purchased from ISO, there’s a draft document which is available in public domains for free.Ĭoming back to our discussion, the NULL macro is defined as ((void *)0) in the header files of most of the C compiler implementations.
#Null vector example iso#
For completeness, let us mention that the previous C standards were C99, C90 (also known as ISO C) and C89 (also known as ANSI C). Please note that ISO/IEC 9899:2011 is the C language’s latest standard which was published in Dec 2011. 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.”īefore we proceed further on this NULL discussion :), let’s mention a few lines about C standard just in case you want to refer to it for further study. “ An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant. Let us see what C standards say about the null pointer.
#Null vector example how to#
How to declare a pointer to a function?.An Uncommon representation of array elements.Dangling, Void, Null and Wild Pointers.

ISRO CS Syllabus for Scientist/Engineer Exam.

