Thread: char

  1. #16
    Registered User
    Join Date
    Feb 2011
    Posts
    14
    Thanks.
    Is yours (your routine) better in any way ?

  2. #17
    Registered User
    Join Date
    Aug 2006
    Posts
    12
    Quote Originally Posted by chris04585 View Post
    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

  3. #18
    Registered User
    Join Date
    Feb 2011
    Posts
    14
    ok, thanks a lot for your help. Really helpful.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. Sorting Linked Lists
    By DKING89 in forum C Programming
    Replies: 6
    Last Post: 04-09-2008, 07:36 AM
  3. code condensing
    By bcianfrocca in forum C++ Programming
    Replies: 4
    Last Post: 09-07-2005, 09:22 AM
  4. Passing structures... I can't get it right.
    By j0hnb in forum C Programming
    Replies: 6
    Last Post: 01-26-2003, 11:55 AM
  5. String sorthing, file opening and saving.
    By j0hnb in forum C Programming
    Replies: 9
    Last Post: 01-23-2003, 01:18 AM