Thanks.
Is yours (your routine) better in any way ?
Thanks.
Is yours (your routine) better in any way ?
Not really, apart from allowing you to find 'binary' keys too.
I tried to write a routine that shows you how it would work. memcmp() works fine too. I was under the impression I could make it a bit more efficient and get rid of the extra loop hidden in the memcmp() function. Unfortunately you really need to rewind the source index when you fail to match the key, so the complexity stays the same as with using memcmp().
LT
PS: While I am here, maybe I should comment on the fact that in professional software engineering having several return statements in a function is frowned upon. Just saying
Last edited by Lord Thunder; 02-14-2011 at 05:29 PM. Reason: PS :P
ok, thanks a lot for your help. Really helpful.