Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/strcasecmp.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/strcasecmp.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/strcasecmp.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/strcasecmp.html on line 8
Compare two strings, ignoring case
#include <strings.h>
int strcasecmp( const char* str1,
const char* str2 );
- str1, str2
- The strings that you want to compare.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The strcasecmp() function compares two strings, specified by
str1 and str2, ignoring the case of the characters.
- < 0
- s1 is less than s2.
- 0
- s1 is equal to s2.
- > 0
- s1 is greater than s2.
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
void compare( const char* s1, const char* s2 )
{
int retval;
retval = strcasecmp( s1, s2 );
if( retval > 0 ) {
printf( "%s > %s\n", s1, s2 );
} else if( retval < 0 ) {
printf( "%s < %s\n", s1, s2 );
} else {
printf( "%s == %s\n", s1, s2 );
}
}
int main( void )
{
char* str1 = "abcdefg";
char* str2 = "HIJ";
char* str3 = "Abc";
char* str4 = "aBCDEfg";
compare( str1, str2 );
compare( str1, str3 );
compare( str1, str4 );
compare( str1, str1 );
compare( str2, str2 );
compare( str2, str3 );
compare( str2, str4 );
compare( str2, str1 );
return EXIT_SUCCESS;
}
This code produces output that looks like:
abcdefg < HIJ
abcdefg > Abc
abcdefg == aBCDEfg
abcdefg == abcdefg
HIJ == HIJ
HIJ > Abc
HIJ > aBCDEfg
HIJ > abcdefg
POSIX 1003.1 XSI
Safety: | |
Cancellation point |
No |
Interrupt handler |
Yes |
Signal handler |
Yes |
Thread |
Yes |
strcmp(),
strcmpi(),
strcoll(),
stricmp(),
strncasecmp(),
strncmp(),
strnicmp(),
wcscmp(),
wcscoll(),
wcsncmp()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/strcasecmp.html on line 186
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/strcasecmp.html on line 186