Can we always find in two strings, whether which one come first lexicographically using strcmp. I mean suppose in some character set value of 'a' is larger than 'b', then what would be the result of strcmp("a","b") ?
Can we always find in two strings, whether which one come first lexicographically using strcmp. I mean suppose in some character set value of 'a' is larger than 'b', then what would be the result of strcmp("a","b") ?
When in doubt...strcmp definition
Yes, you can determine lexicographical order with strcmp, but what exactly that means will depend on your encoding scheme (ASCII, EBCDIC, etc). Now, generally, this will put "A" before "B" and such, but for example, ASCII puts upper case before lower case, while EBCDIC does the reverse, and while ASCII keeps all upper case letters contiguous and all lower case letters, EBCDIC has the occasional punctuation mark in between letter groups.Originally Posted by man strcmp
It's unlikely you're using EBCDIC, (you're probably using ASCII or some UTF encoding) but it is worth noting in case you do work on a system with a different encoding scheme.
Last edited by anduril462; 09-21-2011 at 12:21 PM.
@AndrewHunter
I know that definition , but still I was confused thats why I posted here, seems like you don't understand my question.
In C programming a modern approach author said that strcmp(s1,s2) return value smaller than 0, 0, greater than zero depending upon s1 is smaller than s2 or equal or s2 is smaller than s1.
Now if we see "a" and "b" lexicographically than "a" is smaller than "b", but suppose in some character set 'a' s value is greater than 'b' than it should return +ve value according to standard definition, which means "a" is larger than "b" which obviously is not true as far as I can see.
So I want clarification for this only
Thanks
Last edited by _arjun; 09-21-2011 at 12:29 PM.