This is basic example i created to understand Pointers
code:
Output:
Code Analysis:
code:
/*www.mycfiles.com
Basic Example to Understand Pointer's*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a=20,*p,**k;
clrscr();
p=&a;
k=&p; /* here *p is pointer of a & **k of *p */
printf("\n1.Value of a=%d",a);
printf("\n\n2.Address of a=%u",&a);
printf("\n\n3.Value of p=%u",p);
printf("\n\n4.Value of a=%d",*p);
printf("\n\n5.Address of pointer p=%u",&p);
printf("\n\n6.Value of k=%u",k);
getch();
}
Basic Example to Understand Pointer's*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a=20,*p,**k;
clrscr();
p=&a;
k=&p; /* here *p is pointer of a & **k of *p */
printf("\n1.Value of a=%d",a);
printf("\n\n2.Address of a=%u",&a);
printf("\n\n3.Value of p=%u",p);
printf("\n\n4.Value of a=%d",*p);
printf("\n\n5.Address of pointer p=%u",&p);
printf("\n\n6.Value of k=%u",k);
getch();
}
Output:
Code Analysis:
Here we took 1 variable a whose value is 20
*p is a pointer of a & **k is pointer of *p
Put this in mind
Value of a=20
Address of a=65524
Value of p=65524(Address of a=65524)
Address of p=65522
Value of k=65522(Address of p=65522)
