Search code examples
cmemcmp

Merit of signed comparison return of memcmp


What is a merit for the signed int return value of memcmp compared to say bool?

I don't think I've ever used the return value of memcmp other than to compare it against zero.


Solution

  • What is a merit for the signed int return value of memcmp

    Useful for sorting objects based on their binary representation.

    Note: memcmp() returns a +,0,- based on the first mismatched byte as if bytes are unsigned char, not char.