4 ms·
I'm just a C newbie, so I can't give you a definitive answer. Here's two I came up with: If you know the bounds of the array, then you could enumerate it and c
by Sacho 10y ago
I'm just a C newbie, so I can't give you a definitive answer. Here's two I came up with:
If you know the bounds of the array, then you could enumerate it and check if the pointers to any of its elements are equal to your pointer.
Alternatively you could store references to array elements as a structure of a start pointer + offset, and arrays as a pair of start and end pointers. Then checking if a reference points to part of the array would be a two-step operation - check that the starts match and that your offset is within the end - start bounds.