strcasecmp in C returns 156 instead of 0, any ideas why?

Posted by hora on Stack Overflow See other posts from Stack Overflow or by hora
Published on 2010-03-25T01:27:20Z Indexed on 2010/03/25 1:33 UTC
Read the original article Hit count: 337

Filed under:
|
|
|

I have the following code:

printf("num: %d\n", strcasecmp(buf, "h\n"));

And I get the following results when I try plugging in different letters:

a: -7
g: -1
i: 1
j: 2
h: 156
H: 156

Should strcasecmp not return 0 when buf is equal to H or h? Any ideas why it's returning 156? I need to figure out how to check whether the user types H or h.

Thanks!

© Stack Overflow or respective owner

Related posts about c

    Related posts about string-manipulation