所有栏目

strncasecmp

作者:爱百科

这个函数在linux下man 手册中的定义 :

strncasecmp介绍

这个函数在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.

strncasecmp函数信息

相关函数:bcmp, memcmp, strcmp, strcoll, strncmp

表头文件:#include <strings.h>

函数定义:int strncasecmp(const char *s1, const char *s2, size_t n)

函数说明:strncasecmp()用来比较参数s1和s2字符串前n个字符,比较时会自动忽略大小写的差异。

strncasecmp其他信息

返回值 :

若参数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中提供。

热点导航
教育资讯 知道问答 公考资讯 司法考试 建筑知识 工作范文 大学排名 报考专业 学习方法 句子美文 秒知回答 作业解答 精选答案 知途问学