1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Searching for a particular address in a given range

Discussion in 'C' started by xyz1987, Nov 20, 2010.

  1. xyz1987

    xyz1987 New Member

    Joined:
    Nov 20, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. crazyNut

    crazyNut New Member

    Joined:
    Nov 21, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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?
     
  3. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     

Share This Page