_memicmp_memicmp_l

比较两个缓冲区中的字符(不区分大小写)。

语法

int _memicmp(
   const void *buffer1,
   const void *buffer2,
   size_t count
);
int _memicmp_l(
   const void *buffer1,
   const void *buffer2,
   size_t count,
   _locale_t locale
);

参数

buffer1
第一个缓冲区。

buffer2
第二个缓冲区。

count
字符数。

locale
要使用的区域设置。

返回值

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

返回值 buf1 和 buf2 的第一个计数字节的关系
< 0 buffer1 小于 buffer2
0 buffer1 等于 buffer2
> 0 buffer1 大于 buffer2
_NLSCMPERROR 出现了错误。

注解

_memicmp 函数逐字节地比较两字节缓冲区 countbuffer1 中的第一个 buffer2 字符。 该比较不区分大小写。

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

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

默认情况下,此函数的全局状态范围限定为应用程序。 若要更改此行为,请参阅 CRT 中的全局状态

要求

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

有关兼容性的详细信息,请参阅 兼容性

示例

// 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.

另请参阅

缓冲区操作
_memccpy
memchrwmemchr
memcmpwmemcmp
memcpywmemcpy
memsetwmemset
_stricmp_wcsicmp_mbsicmp_stricmp_l_wcsicmp_l_mbsicmp_l
_strnicmp_wcsnicmp_mbsnicmp_strnicmp_l_wcsnicmp_l_mbsnicmp_l