_memicmp、_memicmp_l
比较两个缓冲区的字符 (不区分大小写)。
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 |
---|---|
< 0 |
buf1 小于 buf2 |
0 |
buf1 等于 buf2。 |
> 0 |
buf1 大于 buf2。 |
_NLSCMPERROR |
发生错误。 |
备注
_memicmp 函数的字节比较两字节缓冲区 buf1 和 buf2 中的第一个 count 字符。 该比较不区分大小写。
如果 buf1 或 buf2都 是空指针,则会调用无效参数处理程序,如 参数验证 所述。 如果允许执行继续,则该函数返回 _NLSCMPERROR 并将 errno 设置为 EINVAL。
_memicmp使用相关行为的当前区域设置;和_memicmp_l 相同,但它将使用传递的区域设置。 有关详细信息,请参阅区域设置。
要求
例程 |
必需的标头 |
---|---|
_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" );
}
.NET Framework 等效项
不适用。若要调用标准 C 函数,请使用 PInvoke。有关更多信息,请参见平台调用示例。
请参见
参考
_stricmp、_wcsicmp、_mbsicmp、_stricmp_l、_wcsicmp_l、_mbsicmp_l
_strnicmp、_wcsnicmp、_mbsnicmp、_strnicmp_l、_wcsnicmp_l、_mbsnicmp_l