We can also subtract one pointer from another pointer. This technique is useful when we need to calculate the number of bytes between the two pointers. But pointers subtraction is useful when they are pointing the same array or memory block.
If subtract two pointers that pointing the same array, the result of this subtraction gives the number of elements that separate them. Let’s consider two examples which describe the subtraction of two number.
Example 1:
In this example, we will calculate the size of the structure to subtract the pointers.
Output: Size of structure = 8