#include <assert.h>
//比较忽略大小写
int mystrcasecmp(const char *s1, const char *s2)
{
assert( s1 != NULL && s2 != NULL);
int str1 = 0,str2 = 0;
while( *s1 != '\0' || *s2 != '\0')
{
str1 = *s1;
str2 = *s2;
if( *s1 >= 'A' && *s1 <= 'Z')
{
str1 = *s1-'A'+'a';
}
if( *s2 >= 'A' && *s2 <= 'Z')
{
str2 = *s2-'A'+'a';
}
if( str1 != str2)
{
return str1-str2;
}
s1++;
s2++;
}
return 0;
}
C语言字符函数strcasecmp的实现
于 2021-12-18 16:12:54 首次发布