共用方式為


_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 前 count 位元組的大小關係

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

如需更多關於相容性的資訊,請參閱入門介紹中的 相容性 (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" );
}
  

.NET Framework 對等用法

不適用。若要呼叫標準 C 函式,請使用 PInvoke。如需詳細資訊,請參閱平台叫用範例

請參閱

參考

緩衝區操作

_memccpy

memchr、wmemchr

memcmp、wmemcmp

memcpy、wmemcpy

memset、wmemset

_stricmp、_wcsicmp、_mbsicmp、_stricmp_l、_wcsicmp_l、_mbsicmp_l

_strnicmp、_wcsnicmp、_mbsnicmp、_strnicmp_l、_wcsnicmp_l、_mbsnicmp_l