Differencing Pointer in C Programming Language :
- Differencing Means Subtracting two Pointers.
- Subtraction gives the Total number of objects between them .
- Subtraction indicates “How apart the two Pointers are “
Example :
#include<stdio.h> int main() { int num , *ptr1 ,*ptr2 ; ptr1 = &num ; ptr2 = ptr1 + 2 ; printf("%d",ptr2 - ptr1); return(0); }
Output :
2
- ptr1 stores the address of Variable num
- Value of ptr2 is incremented by 4 bytes
- Differencing two Pointers
Observations & Explanation :
- Numerically Subtraction ( ptr2-ptr1 ) differs by 4
- As both are Integers they are numerically Differed by 4 and Technically by 2 objects
- Suppose Both pointers of float the they will be differed numerically by 8 and Technically by 2 objects

