这个函数在linux下man 手册中的定义 :
这个函数在linux下man 手册中的定义 :
The strcasecmp() function compares the two strings s1 and s2, ignoring the case of the characters. It returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2. The strncasecmp() function is similar, except it compares the only first n bytes of s1.
相关函数:bcmp, memcmp, strcmp, strcoll, strncmp
表头文件:#include <strings.h>
函数定义:int strncasecmp(const char *s1, const char *s2, size_t n)
函数说明:strncasecmp()用来比较参数s1和s2字符串前n个字符,比较时会自动忽略大小写的差异。
返回值 :
若参数s1和s2字符串相同,则返回0;
若s1大于s2,则返回大于0的值;
若s1小于s2,则返回小于0的值。
注意 : 在linux在这个函数并不是 头文件 #include<string.h> 而是 头文件 #include<strings.h>
#include <strings.h>
main()
{
char *a="aBcddfefekr";
char *b="AbCddfefekr";
printf("%dn", strncasecmp(a, b, 11));
}
亦可用在指定结束与程序入口
eg:if(!strncasecmp(buffer,"quit",4))
break;
eg:if(!strncasecmp(buffer,"work",4)){
printf("hello,world!");
break;
}
注意:此函数只在Linux中提供。