当前位置:首页 科普知识 strncasecmp

strncasecmp

发布时间:2023-09-14 19:56:33

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

strncasecmp介绍

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

strncasecmp

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>

strncasecmp

#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)){

strncasecmp

printf("hello,world!");

break;

}

注意:此函数只在Linux中提供。

温馨提示:
本文【strncasecmp】由作者 爱百科 转载提供。 该文观点仅代表作者本人, 自学教育网 信息发布平台,仅提供信息存储空间服务, 若存在侵权问题,请及时联系管理员或作者进行删除。
(c)2008-2025 自学教育网 All Rights Reserved 汕头市灵创科技有限公司
粤ICP备2024240640号-6