in my eyes should always be equal or the function returns an int equal to false
The comparison is a three-digit comparison: negative / zero / positive are important types of return value, not just true / false. It returns int to false if the strings are equal, and not if they are not.
If you lexically arrange (under) strings of different lengths, compare will tell you in what order they come.
If everything you care about is tantamount (by), then different lengths mean not equal. As an optimization, you can skip the compare call if n1 != n2 .
source share