Originally Posted by
nonpuz
If *low and *high point to the same memory block, (ie you char * p = malloc(100); and assign points to this same object) then the memory is in fact in order and linear...so you can already do a binary search on it because the address ARE sorted.
Though as early pointed out if you know the address, you would just access it directly; therefore perhaps hes meaning how do I find the letter pointed to by *somep within the range low, high, which are boundaries pointing into a string?? In which case we just suggest strchr() or a for loop...
But all this also begs the question of why do we need to search if we already know the address...
Perhaps our vague friend wants to know if a given pointer is between two other pointers (i.e. in a given range) in which case a simple if() statement will suffice...
Code:
int InRange(char *ptr, char *start, char *end)
{ return (ptr >= start) && (ptr <= end); }