fork(6) download
  1. #include<stdio.h>
  2.  
  3. int main(void)
  4. {
  5. // Declaring a void pointer
  6. void *vptr;
  7.  
  8. // Creating some pointer variables
  9. int arr[5]={34,5,17,39,1};
  10. int *ptr1,*ptr,num,i;
  11.  
  12. vptr=arr;
  13.  
  14. ptr=(int *)vptr; // casting void *
  15.  
  16. ptr1=arr+3; // pointer and integer addition
  17.  
  18. if(ptr1 > ptr) //comparison of pointers
  19. num=ptr1-ptr; // subtraction of pointers
  20.  
  21. printf("% d,% d,% d\n",*ptr,*ptr1,num);
  22.  
  23. ptr = ptr1-2; //pointer and integer subtraction ,pointer assignment of same types
  24. ptr1++; //pointer increment
  25.  
  26. printf("% d,% d\n",*ptr,*ptr1);
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 2008KB
stdin
Standard input is empty
stdout
 34, 39, 3
 5, 1