Challenge: Implement memcmp

Test your knowledge by solving this coding challenge.

The memcmp function

The memcmp function comes from the C standard library. It allows us to compare two memory areas for equality at the byte level.

The header is as follows:

int memcmp(const void* ptr1, const void* ptr2, size_t num);

It compares the first num bytes of ptr1 against the first num bytes of ptr2. It returns the following:

  • < 0 if the blocks are not equal and the first byte that doesn’t match is smaller in ptr1 than ptr2.
  • = 0 if the blocks are
...