I am writing a program that simulates the race between the tortoise and the hare.
They both move along two distinct one-dim array of 70 elements and, of course, since they move forward and backward they might wind up beyond the element 0 or 69.
I want to use pointers comparison to check if they did, so here comes the question:
i know that pointers comparison is legit if we are comparing pointers that point to elements of the same array, because otherwise we can't be sure of their position in memory; still, suppose we have:
char arr[70];
char *p1 = &arr[0]
char *p2 = &arr[69]
can't we be sure that p1 > p1 - 3 and p2 < p2 + 6 , because, in this case, the addresses will be contiguous? We know for certain which comes first and whatnot, right?
I did various tests and it appears to be so, but i wanted to be sure.