Monday, 5 September 2011

pointer concept with example

#include<stdio.h>
#include<conio.h>
void main()
{
int i;
static int a[]={0,1,2,3,4};
int *p[]={a,a+1,a+2,a+3,a+4};
int **ptr=p;



clrscr();
ptr++;
printf("%d%d%d",ptr-p,*ptr-a,**ptr);
ptr++;
printf("\n");
printf("%d%d%d",ptr-p,*ptr-a,**ptr);
*(++ptr);
printf("\n");

printf("%d%d%d",ptr-p,*ptr-a,**ptr);
printf("\n");
++(*ptr);
printf("%d%d%d",ptr-p,*ptr-a,**ptr);

getch();

}


output

1 1 1

2 2 2

3 3 3

3 4 4

No comments:

Post a Comment