When two pointers are subtracted, both must point to elements of the same array object or just one past the last element of the array object (C Standard, subclause 6.5.6 [ISO/IEC 9899:2011]); the result is the difference of the subscripts of the two array elements. Otherwise, the operation is undefined behavior (see undefined behavior 48).
...