C Language - Null Pointer

 



#include <stdio.h>


int main()

{

int a=345;

int b=53;

int c= 34;

int *ptr = &a;

int *shan = &b;

int *ali = NULL;

printf ("The value of a is %d\n", *ptr);

printf ("The address of a is %d\n", ptr);


printf ("The value of b is %d\n", *shan);

printf ("The address of b is %d\n", shan);


printf ("The address of c is %d\n", ali);


if (ali !=NULL) 

{

printf ("The value of c is %d\n", *ali);


else {

printf ("The pointer is a NULL pointer and cannot be derefernced");

}


}


// ScreenShots:



Comments

Popular Posts