Null Pointer in C - Null Pointer
Learn C - C tutorial - nullpointer in c - C examples - C programs
Null Pointer in C
- Null pointer is a special reserved value of a pointer.
- Each particular pointer type { int *, char * etc...,} has its own null-pointer value.
- When a pointer has null value it is not pointing anywhere.
Learn C - C tutorial - nullpointer in c - C examples - C programs
Sample Code
#include <stdio.h>
int main()
{
int *ptr;/*integer pointer*/
ptr=NULL;/*NULL to pointer*/
printf("NULL Macro: %d\n",NULL);
printf("NULL pointer: %p\n",ptr);
return 0;
}
Output
NULL Macro: 0
NULL pointer: (nil)