According to the C standard (N1570 7.24.4.2):
The strcmp
function returns an integer greater than, equal to,
or less than zero, accordingly as the string pointed to by s1
is
greater than, equal to, or less than the string pointed to by
s2
.
It says nothing about which positive or negative value it will return if the strings are unequal, and portable code should only check whether the result is less than, equal to, or greater than zero.
Having said that, a straightforward implementation of strcmp
would likely return the numeric difference in the values of the first characters that don't match. In your case, the first non-matching characters are 'c'
and 'C'
, which happen to differ by 32 in ASCII.
Don't count on this.