#include<stdio.h>
int main(void)
{
// Declaring a void pointer
void *vptr;
// Creating some pointer variables
int arr[5]={34,5,17,39,1};
int *ptr1,*ptr,num,i;
vptr=arr;
ptr=(int *)vptr; // casting void *
ptr1=arr+3; // pointer and integer addition
if(ptr1 > ptr) //comparison of pointers
num=ptr1-ptr; // subtraction of pointers
printf("% d,% d,% d\n",*ptr
,*ptr1
,num
);
ptr = ptr1-2; //pointer and integer subtraction ,pointer assignment of same types
ptr1++; //pointer increment
printf("% d,% d\n",*ptr
,*ptr1
);
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KCmludCBtYWluKHZvaWQpCnsKCS8vIERlY2xhcmluZyBhIHZvaWQgcG9pbnRlcgoJdm9pZCAqdnB0cjsKCQoJLy8gQ3JlYXRpbmcgc29tZSBwb2ludGVyIHZhcmlhYmxlcwoJaW50IGFycls1XT17MzQsNSwxNywzOSwxfTsKCWludCAqcHRyMSwqcHRyLG51bSxpOwoJCgl2cHRyPWFycjsKCQoJcHRyPShpbnQgKil2cHRyOwkvLyAgY2FzdGluZyB2b2lkICoKCQoJcHRyMT1hcnIrMzsJCSAgIC8vIHBvaW50ZXIgYW5kIGludGVnZXIgYWRkaXRpb24KCQoJaWYocHRyMSA+IHB0cikJCSAgICAgLy9jb21wYXJpc29uIG9mIHBvaW50ZXJzCgkJbnVtPXB0cjEtcHRyOwkJLy8gc3VidHJhY3Rpb24gb2YgcG9pbnRlcnMKCglwcmludGYoIiUgZCwlIGQsJSBkXG4iLCpwdHIsKnB0cjEsbnVtKTsKCQoJcHRyID0gcHRyMS0yOwkJLy9wb2ludGVyIGFuZCBpbnRlZ2VyIHN1YnRyYWN0aW9uICxwb2ludGVyIGFzc2lnbm1lbnQgb2Ygc2FtZSB0eXBlcwoJcHRyMSsrOwkJCSAgICAvL3BvaW50ZXIgaW5jcmVtZW50CgkKCXByaW50ZigiJSBkLCUgZFxuIiwqcHRyLCpwdHIxKTsKCQoJcmV0dXJuIDA7Cn0K