# include <stdio.h>
# include <conio.h>
main(){
int no=100; /* decl of int variable */
int*ptr; /* decl of int* */
ptr=&no; /* init int var address to poi */
clrscr();
printf("\n%d",*ptr);
printf("\n%x %x %x",&ptr,ptr,&no);
*ptr=200;
printf("\n%d",*ptr);
/* char poi */
char ch='A';
char*cptr;
cptr=&ch;
printf("\n%c",*cptr);
/* array vs poi */
int n[]={10,20,30,40,50};
ptr=&n[2]; /* or ptr=n; initializing 2nd index to poi*/
*(ptr+2)=100;
printf("\n%d %d",*(ptr+2),n[2]);
/* address decrementing and incrementing by 2b */
*ptr--;
printf("\n%d",*ptr);
*ptr++;
printf("\n%d",*ptr);
/* void pointers */
void*vptr;
vptr=&n[0];
printf("\n%d",*(int*)vptr);
vptr=&ch;
printf("\n%c",*(char*)vptr); /* type casting to char /*
char*str="Ongole";
vptr=str;
printf("\n%s",(char*)vptr);
printf("\n%c",*(char*)vptr);
/* dynamically allocating 10b memory to pointer */
ptr=(int*)malloc(sizeof(int)*5);
/* deleting memory */
free(ptr);
}
# include <conio.h>
main(){
int no=100; /* decl of int variable */
int*ptr; /* decl of int* */
ptr=&no; /* init int var address to poi */
clrscr();
printf("\n%d",*ptr);
printf("\n%x %x %x",&ptr,ptr,&no);
*ptr=200;
printf("\n%d",*ptr);
/* char poi */
char ch='A';
char*cptr;
cptr=&ch;
printf("\n%c",*cptr);
/* array vs poi */
int n[]={10,20,30,40,50};
ptr=&n[2]; /* or ptr=n; initializing 2nd index to poi*/
*(ptr+2)=100;
printf("\n%d %d",*(ptr+2),n[2]);
/* address decrementing and incrementing by 2b */
*ptr--;
printf("\n%d",*ptr);
*ptr++;
printf("\n%d",*ptr);
/* void pointers */
void*vptr;
vptr=&n[0];
printf("\n%d",*(int*)vptr);
vptr=&ch;
printf("\n%c",*(char*)vptr); /* type casting to char /*
char*str="Ongole";
vptr=str;
printf("\n%s",(char*)vptr);
printf("\n%c",*(char*)vptr);
/* dynamically allocating 10b memory to pointer */
ptr=(int*)malloc(sizeof(int)*5);
/* deleting memory */
free(ptr);