#include <stdio.h>
int main ()
{
int var1;
char var2[10];
printf("Address of var1 variable: %x\n", &var1 );
printf("Address of var2 variable: %x\n", &var2 );
return 0;
}
include <stdio.h>
in the above code is compiled and executed, it produces the following result:
Address of var1 variable: bff5a400
Address of var2 variable: bff5a3f6
It is always a good practice to assign a NULL value to a pointer variable in case you do not have an exact address to be assigned. This is done at the time of variable declaration. A pointer that is assigned NULL is called a null pointer.
The NULL pointer is a constant with a value of zero defined in several standard libraries. Consider the following program:
#include <stdio.h>
int main ()
{
int *ptr = NULL;
printf("The value of ptr is : %x\n", ptr );
return 0;
}
When the above code is compiled and executed, it produces the following result:
The value of ptr is 0
Thanks Sir,I have learnt pointer deeply by your blog.. thank you again😃😄
ReplyDelete