diff between memcmp and strcmp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sahilmakkar
    New Member
    • Aug 2006
    • 1

    #1

    diff between memcmp and strcmp

    can anybody tell me what is difference between memcmp and strcmp

    which one is better
    efficient
    and when to use memcmp or strcmp
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    They both compare char for char, however memcmp takes the number of characters to compare, strcmp assumes the pointers passed to it are pointers to strings which zero terminators.

    Generally use strcmp when comparing strings, this makes it clear what you are doing, use memcmp when you are comparing anything other than strings.

    I would imagine that there was not much difference in efficiency but I might be wrong.

    Comment

    Working...