Compare two strings, ignoring case
#include <string.h> int strcmpi( const char* s1, const char* s2 );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The strcmpi() function compares the string pointed to by s1 to the string pointed to by s2, ignoring case.
All uppercase characters from s1 and s2 are mapped to lowercase for the purposes of doing the comparison. The strcmpi() function is identical to the stricmp() function.
#include <stdio.h> #include <string.h> #include <stdlib.h> int main( void ) { printf( "%d\n", strcmpi( "AbCDEF", "abcdef" ) ); printf( "%d\n", strcmpi( "abcdef", "ABC" ) ); printf( "%d\n", strcmpi( "abc", "ABCdef" ) ); printf( "%d\n", strcmpi( "Abcdef", "mnopqr" ) ); printf( "%d\n", strcmpi( "Mnopqr", "abcdef" ) ); return EXIT_SUCCESS; }
produces the output:
0 100 -100 -12 12
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
strcasecmp(), strcmp(), strcoll(), stricmp(), strncasecmp(), strncmp(), strnicmp(), wcscmp(), wcscoll(), wcsncmp()