Pointer Type Declaration
Consider
the following program –
#include<stdio.h>
void
main()
{
int
n; // normal integer variable storing value
int
*ptr; //
since '*' is used, hence it is a pointer variable storing addres of value
n
= 10;
/*
'&' returns the address of the
variable 'i'
which is stored in the pointer variable
'a'
*/
ptr
= &n;
printf("\nAddress
of n is : %u",&n); //output
let 65524
printf("\nAddress
of ptr is : %u",&ptr); //output let 65522
printf("\nValue
of n is : %d", n); // output is 10
printf("\nValue
of ptr is : %u",ptr); // output is 65524
printf("\nValue
pointed thr ptr is : %d", *ptr); // output is 10
}
After
declaration memory map will be like this –
int
i = 10;
int
*ptr;
After Assigning the address of variable
to pointer , i.e after the execution of this statement –
ptr
= &i;
