_memicmp、_memicmp_l

 用法:#include <string.h>
  
 功能:比较内存区域buf1和buf2的前count个字节但不区分字母的大小写。
  
 说明:memicmp同memcmp的唯一区别是memicmp不区分大小写字母
        当buf1<buf2时,返回值<0
        当buf1=buf2时,返回值=0
        当buf1>buf2时,返回>0

int _memicmp(  
   const void *buf1,  
   const void *buf2,  
   size_t count   
);  
int _memicmp_l(  
   const void *buf1,  
   const void *buf2,  
   size_t count,  
   _locale_t locale  
);  

参数

buf1
第一个缓冲区。

buf2
第二个缓冲区。

count
字符数。

locale
要使用的区域设置。

返回值指示在缓冲区之间的关系。

返回值buf1 和 buf2 的第一个计数字节的关系
&lt; 0buf1 小于 buf2
0buf1 等于 buf2
&gt; 0buf1大于buf2
_NLSCMPERROR出现了错误。

如果任一buf1buf2是 null 指针,此函数将调用无效参数处理程序中,如中所述数验证。 如果允许继续执,则函数将返回 _NLSCMPERROR,并且将 errno 设置为 EINVAL

_memicmp 将当前区域设置用于与区域设置相关的行为;_memicmp_l 也是一样,只不过它使用传入的区域设置。 有关详细信息,请参阅 Locale

例程必需的标头
_memicmp<memory.h> 或 <string.h>
_memicmp_l<memory.h> 或 <string.h>

有关更多兼容性信息,请参阅“简介”中的 Compatibility 。

// crt_memicmp.c  
// This program uses _memicmp to compare  
// the first 29 letters of the strings named first and  
// second without regard to the case of the letters.  
  
#include <memory.h>  
#include <stdio.h>  
#include <string.h>  
  
int main( void )  
{  
   int result;  
   char first[] = "Those Who Will Not Learn from History";  
   char second[] = "THOSE WHO WILL NOT LEARN FROM their mistakes";  
   // Note that the 29th character is right here ^  
  
   printf( "Compare '%.29s' to '%.29s'\n", first, second );  
   result = _memicmp( first, second, 29 );  
   if( result < 0 )  
      printf( "First is less than second.\n" );  
   else if( result == 0 )  
      printf( "First is equal to second.\n" );  
   else if( result > 0 )  
      printf( "First is greater than second.\n" );  
}  

Compare 'Those Who Will Not Learn from' to 'THOSE WHO WILL NOT LEARN FROM'  
First is equal to second.  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值