Syntax
#include <string.h> int strcoll(const char *string1, const char *string2);Description
strcoll compares the string pointed to by string1 against the string pointed to by string2, both interpreted according to the information in the LC_COLLATE category of the current locale.
strcoll differs from the strcmp function. strcoll performs a comparison between two character strings based on language collation rules as controlled by the LC_COLLATE category. In contrast, strcmp performs a character to character comparison.
strcoll returns an integer value indicating the relationship between the strings, as listed below: compact break=fit.
Value
Note:
This example compares the two strings passed to main.
#include <stdio.h>#include <string.h> int main(int argc,char **argv) { int result; if (argc != 3) { printf("Usage: %s string1 string2\n", argv[0]); } else { result = strcoll(argv[1], argv[2]); if (0 == result) printf("\"%s\" is identical to \"%s\"\n", argv[1], argv[2]); else if (result < 0) printf("\"%s\" is less than \"%s\"\n", argv[1], argv[2]); else printf("\"%s\" is greater than \"%s\"\n", argv[1], argv[2]); } return 0; /**************************************************************************** If the program is passed the following arguments: "firststring" "secondstring" The output should be: "firststring" is less than "secondstring" ****************************************************************************/ }Related Information