Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
#include <string.h>
int strcoll(const char *string1, const char *string2);
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.
⁄* CELEBS37
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 ( result == 0 )
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] );
}
}
Output
"firststring" is less than "secondstring"