I found an implementation of the function strcmp I showed it to a friend and he said the following "It's worth noting that it doesn't always return the difference between the two differing characters; it is actually permitted to return any integer provided the sign is the same as the difference between the bytes." then gave me no further explanation, the code is this
int
strcmp(s1, s2)
register const char *s1, *s2;
{
while (*s1 == *s2++)
if (*s1++ == 0)
return (0);
return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1));
}
Can someone explain what is the error? and what kind of string can cause failure?