Say we have this piece of C
code:
int x[] = {1, 2, 3, 4, 5};
printf("%d", *(x + 1)); //prints 2
printf("%d", *(x + 500)); //prints 7209065 (...?)
As you can see from the second call, it still returns something...but it's garbage.
So I ask, how do you handle such a case in C? ie, how do you know if the returned element is really an element that exists in the array or just garbage ?