&gt; Use:
&gt; ptrdiff_t diff = (uintptr_t)ptrOld - (uintptr_t)ptrNew;<p>The casts to uintptr_t are not needed in this case, as the result of subtracting two pointers already yields ptrdiff_t.<p>Also, the mere subtraction of two pointers that do not point to the same &quot;array object&quot; yields undefined behaviour as per the standard.