windows API 第八篇 _tcsicmp _stricmp _wcsicmp _mbsicmp

本文介绍三种用于比较字符串并忽略大小写的函数:_stricmp, _wcsicmp 和 _mbsicmp。这些函数分别用于比较ANSI字符串、宽字符字符串和多字节字符串。文章详细解释了函数的用法、返回值及示例代码。
这些函数都是比较字符串小写的,忽略大写,出入的字符串都将按照小写比较
Perform a lowercase comparison of strings.

函数原型:

int _stricmp( const char *string1, const char *string2 );        //#include <string.h>

int _wcsicmp( const wchar_t *string1, const wchar_t *string2 );    //#include <string.h> or  <wchar.h>

int _mbsicmp( const unsigned char *string1, const unsigned char_t *string2 );    //#include <mbstring.h>

返回值:

0: string1 identical to string2         <0:string1 less than  string2             >0:string1 greater than string2

举例:
char *str1 = "abc";
char *str2 = "AbC";
int  nResult = _stricmp(str1, str2);         //nResult = 0

wchar_t szStr1[] = "asdfg";
wchar_t szStr2[] = "AsDfG";
int nResult = _wcsicmp(szStr1, szStr2);      //nResult = 0

至于_mbsicmp是比较无符号字符串的,可根据情况自行使用

转载于:https://www.cnblogs.com/priarieNew/p/9754168.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值