Null Pointer
It is a pointer that does not point to any memory location. It represents an invalid memory location.
Â
When NULL value is assigned to a pointer, then it is considered as NULL Pointer.
Â
Uses of NULL Pointer:
- Used to initialise pointer
- Useful to handling errors in dynamic memory allocation
Â
The value of NULL is 0. We can use either NULL or 0 to initialise pointer but 0 is not integer here.
Â
Size of the NULL pointer depends upon the platform and is similar to the size of normal pointer.
Â
It is a good practice to initialise a pointer as NULL.
It is also a good practice to perform NULL check before dereferencing any pointer to avoid surprises.
Â
#include<stdio.h>
Â
void main()
{
   int *ptr=NULL;
   printf(“%d”,ptr);
   printf(“n%d”,sizeof(NULL));
Â
}