S
Sidney Cadot
Hi all,
Just browsing through my newly-acquired C99 spec, I was reading on the
memcmp() function (7.21.4.1). It has a rather peculiar wording:
int memcmp(const void *s1, const void *s2, size_t n);
1. The memcmp function compares the first n characters of the object
pointed to by s1 to the first n characters of the object pointed to by s2.
2. The memcmp function returns an integer greater than, equal to, or
less than zero, accordingly as the object pointed to by s1 is greater
than, equal to, or less than the object pointed to by s2.
What do "greater than", "equal to", or "less than" mean in relation to
the objects pointed to by s1 or s2?
If I implement a C library that does signed-byte one-complement
bit-reversed comparisons on the bytes, in reverse order (starting from
(char *)s1[n-1] and (char *)s2[n-1], going down), would this be compliant?
Best regards,
Sidney
Just browsing through my newly-acquired C99 spec, I was reading on the
memcmp() function (7.21.4.1). It has a rather peculiar wording:
int memcmp(const void *s1, const void *s2, size_t n);
1. The memcmp function compares the first n characters of the object
pointed to by s1 to the first n characters of the object pointed to by s2.
2. The memcmp function returns an integer greater than, equal to, or
less than zero, accordingly as the object pointed to by s1 is greater
than, equal to, or less than the object pointed to by s2.
What do "greater than", "equal to", or "less than" mean in relation to
the objects pointed to by s1 or s2?
If I implement a C library that does signed-byte one-complement
bit-reversed comparisons on the bytes, in reverse order (starting from
(char *)s1[n-1] and (char *)s2[n-1], going down), would this be compliant?
Best regards,
Sidney