Let's 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 this case in C? those. how do you know if the returned element is really an element that exists in the array or just garbage?
c arrays
Andreas Grech
source share