I thought strcmp should have returned a positive number if the first line was larger than the second. But this program
#include <stdio.h>
#include <string.h>
int main()
{
char A[] = "A";
char Aumlaut[] = "Ä";
printf("%i\n", A[0]);
printf("%i\n", Aumlaut[0]);
printf("%i\n", strcmp(A, Aumlaut));
return 0;
}
prints 65, -61and -1.
Why? Is there something I'm missing out on?
I thought that maybe the fact that I save as UTF-8 will affect things. You know, because it Äconsists of two characters. But saving as 8-bit encoding and ensuring that lines with a length of 1 do not help, the end result is the same.
What am I doing wrong?
Using GCC 4.3 under 32-bit Linux is here, in case that matters.
source
share