An Example of Null pointer in C
NULL pointer
The word "NULL" is a constant in C language and its value is 0. In case with the pointers - if any pointer does not contain a valid memory address or any pointer is uninitialized, known as "NULL pointer". We can also assign 0 (or NULL) to make a pointer as "NULL pointer".
Example:
In this example, there are 3 integer pointers ptr1, ptr2 and ptr3. ptr1 is initialized with the address of the integer variable num, thus ptr1 contains a valid memory address. ptr2 is uninitialized and ptr3 assigned 0. Thus, ptr2 and ptr3 are the NULL pointers.
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer