Machine-translated by Google. Questions are authored in English.
Top

Discussion

This function offers the quickest way to determine whether two character sequences of the same known length match character for the character up to and including any null character in both.

  • A.strcmp()
  • B.memcmp()
  • C.strncmp()
  • D.no such function

Answer: C

Correct answer: memcmp()

memcmp() is the one to use when both lengths are known: it compares a fixed number of bytes and stops only at a difference, taking no interest in null characters - so nulls inside the data are compared like any other byte. strcmp and strncmp both stop at a terminating null, so neither compares “up to and including” it.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.