忽略大小写字符串比较函数
#include <strings.h>
int strcasecmp(const char *s1, const char *s2);
参数为两个需要比较的字符串
0: 相同
非0: 返回第一个不同的字符相差的数量。
#include <stdio.h>
int main
/* Compare S1 and S2, ignoring case, returning less than, equal to or
greater than zero if S1 is lexicographically less than,
equal to or greater than S2. */
int
__strcasecmp (const char *s1, const char *s2 LOCALE_PARAM)
{
#if defined _LIBC && !defined USE_IN_EXTENDED_LOCALE_MODEL
locale_t loc = _NL_CURRENT_LOCALE;
#endif
const unsigned char *p1 = (const unsigned char *) s1;
const unsigned char *p2 = (const unsigned char *) s2;
int result;
if (p1 == p2)
return 0;
while ((result = TOLOWER (*p1) - TOLOWER (*p2++)) == 0)
if (*p1++ == ‘\0‘)
break;
return result;
}
原文:https://www.cnblogs.com/st17/p/14247797.html