_strnicmp、 _wcsnicmp、 _mbsnicmp、 _strnicmp_l、 _wcsnicmp_l、 _mbsnicmp_l

比較兩個字串字元不考慮大小寫。

重要事項重要事項

_mbsnicmp 和 _mbsnicmp_l 不能用於 Windows 執行階段執行的應用程式。如需詳細資訊,請參閱 CRT 函式不支援使用 /ZW

int _strnicmp(
   const char *string1,
   const char *string2,
   size_t count 
);
int _wcsnicmp(
   const wchar_t *string1,
   const wchar_t *string2,
   size_t count 
);
int _mbsnicmp(
   const unsigned char *string1,
   const unsigned char *string2,
   size_t count 
);
int _strnicmp_l(
   const char *string1,
   const char *string2,
   size_t count,
   _locale_t locale
);
int _wcsnicmp_l(
   const wchar_t *string1,
   const wchar_t *string2,
   size_t count,
   _locale_t locale
);
int _mbsnicmp_l(
   const unsigned char *string1,
   const unsigned char *string2,
   size_t count,
   _locale_t locale
);

參數

  • string1, string2
    要比較的 NULL 結尾字串。

  • count
    要比較的字元數。

  • locale
    使用的地區設定。

傳回值

表示子字串之間的關聯性,如下所示。

傳回值

描述

< 0

string1 的子字串小於 string2 的子字串。

0

string1 中子字串與 string2 子字串相同。

> 0

string1 的子字串大於 string2 的子字串。

在錯誤, _mbsnicmp 會傳回 _NLSCMPERROR,在 STRING.H 和 MBSTRING.H. 定義。

備註

字典 _strnicmp 函式比較,最多, string1 第一個字元 count 和 string2。執行比較不考慮大小寫; _strnicmp 是 strncmp的不區分大小寫的版本。比較結束,則會結束的 null 字元在任何資料之前,在 count 字元進行比較之前。如果字串是等,以便結束的 null 字元在任一字串時為止, count 字元進行比較之前,較短的字串是較少。

從 91 到 96 的字元在為小於的 ASCII 表 (「[」, 「\」, 「]」, 「、」, 「_」,以及「) 評估任何字母字元。這個順序相同的 stricmp。

_wcsnicmp 和 _mbsnicmp 是 _strnicmp 的寬字元和多位元組字元版本。_wcsnicmp 的參數和回傳值是寬字元字串,而 _mbsnicmp 則是多位元組字元字串。_mbsnicmp 表示根據目前的多位元組字碼頁辨識多位元組字元序列並傳回錯誤的 _NLSCMPERROR 。如需詳細資訊,請參閱字碼頁。這三個函式其餘部分的運作相同。這些函式是受沒有 _l 結尾使用其地區設定相關行為的目前地區設定的地區設定所影響的;排列 _l 結尾使用地區設定傳遞的版本。如需詳細資訊,請參閱地區設定

這些函式會驗證它們的參數。如果 string1 或 string2 為 null 指標,無效的參數叫用處理常式,如 參數驗證中所述。如果執行允許繼續執行,這些函式傳回 _NLSCMPERROR 並將 errno 設為 EINVAL。

泛用文字常式對應

TCHAR.H 常式

未定義 _UNICODE & _MBCS

已定義 _MBCS

已定義 _UNICODE

_tcsncicmp

_strnicmp

_mbsnicmp

_wcsnicmp

_tcsnicmp

_strnicmp

_mbsnbicmp

_wcsnicmp

_tcsncicmp_l

_strnicmp_l

_mbsnicmp_l

_wcsnicmp_l

需求

程序

必要的標頭檔

_strnicmp, _strnicmp_l

<string.h>

_wcsnicmp, _wcsnicmp_l

<string.h> 或 <wchar.h>

_mbsnicmp, _mbsnicmp_l

<mbstring.h>

如需其他相容性資訊,請參閱 相容性

範例

請參閱 strncmp範例。

.NET Framework 對等用法

System::String::Compare

請參閱

參考

字串操作 (CRT)

strcat,wcscat _mbscat

strcmp,wcscmp _mbscmp

strcpy, wcscpy, _mbscpy

strncat、 _strncat_l、 wcsncat、 wcsncat_l、 _mbsncat _mbsncat_l

strncmp、 wcsncmp、 _mbsncmp、 _mbsncmp_l

strncpy、 _strncpy_l、 wcsncpy、 _wcsncpy_l、 _mbsncpy、 _mbsncpy_l

strrchr、 wcsrchr、 _mbsrchr、 _mbsrchr_l

_strset、 _strset_l、 _wcsset、 _wcsset_l、 _mbsset、 _mbsset_l

strspn、 wcsspn、 _mbsspn、 _mbsspn_l