|
As Scott pointed out - for bsearch to work the leading portion of the key has to match on at least one character. Writing your own is probably the best option, but given the way that bsearch works, I guess you could have the compare routine itself record the values for the latest high candidate and low candidate. These should be the key values that are either side of where your key would have been if it existed. You could then apply whatever logic you deem appropriate to determine which of the two is the "closest'. Jon Paris Partner400 www.Partner400.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.