Searching for a particular address in a given range

Newbie Member
20Nov2010,14:30   #1
xyz1987's Avatar
Can anyone help me with searching for a particular address in a given range in C. like i have to search for *ptr in range specified by *high and *low. i think it is not same as linear search. can someone provide some input. thanks.
Light Poster
21Nov2010,12:16   #2
crazyNut's Avatar
Hi,

I am also a newbie so correct me if i am wrong.

What I understand from your problem that you want to find an address *ptr in C ranging form *high to *low

say you have three variables
*ptr = 5
*low = 1
*high = 10

then you want to find the address of 5 i.e the offset of 5 in the list if the list elements are
1, 3, 5, 7, 9, 10.

Is it what you are asking?
Mentor
21Nov2010,14:37   #3
xpi0t0s's Avatar
This doesn't make sense. * dereferences the pointers, so if ptr, high and low contain addresses, then *ptr, *high and *low represent the values in memory at those addresses. It also doesn't make any sense that you want to look for ptr when you already have it. So please restate the question.