![]() |
VOOZH | about |
NULL pointer in C At the very high level, we can think of NULL as a null pointer which is used in C for various purposes. Some of the most common use cases for NULL are
As Null pointer always points to null, one would think that Pointer to a Null Pointer is invalid and won't be compiled by the compiler. But it is not the case. Consider the following example:
Not only this program compiles but executes successfully to give the output as Output:
Pointer to a null pointer is valid
Explanation: What happens here is that when a Null pointer is created, it points to null, without any doubt. But the variable of Null pointer takes some memory. Hence when a pointer to a null pointer is created, it points to an actual memory space, which in turn points to null. Hence Pointer to a null pointer is not only valid but important concept.