pointers arithmetic


Address + Number= Address
Address - Number= Address
Address - Address=Number
Address + Address=Illegal
Example:
void main(){
float *ptr=(float *)5000;
ptr=ptr+5;
clrscr();
printf("%d",ptr);
getch();
}
Output:
5020
void main(){
int *p=(int *)1000;
p=p+3;
clrscr();
printf("%d",p);
getch();
}
Output:
1006
Post a Comment