Taking the difference of two pointers is defined by the C Standard only if both pointers point to the same (array) object (or one behind), so the OP's code invokes undefined behaviour. The result could be anything.
From the C11 Standard:
6.5.6/9 Additive operators
When two pointers are subtracted, both shall point to elements of the same array object,
or one past the last element of the array object; the result is the difference of the
subscripts of the two array elements. The size of the result is implementation-defined,
and its type (a signed integer type) is ptrdiff_t
defined in the <stddef.h>
header.
If the result is not representable in an object of that type, the behaviour is undefined.
The following code is valid:
#include <stdio.h>
int main()
{
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int * i = a + 0;
int * j = a + 10; /* Points "one past the last element" of the array. */
printf("%td \n", i - j);
return 0;
}
It also prints 10
.