strnicmp,_mbsnicmp,_wcsnicmp

提供: RAD Studio
移動先: 案内検索

string.h:インデックス への移動


ヘッダーファイル

string.h, mbstring.h

カテゴリ

メモリと文字列の操作ルーチン

プロトタイプ

int strnicmp(const char *s1, const char *s2, size_t maxlen);

int _wcsnicmp(const wchar_t *s1, const wchar_t *s2, size_t maxlen);

int _mbsnicmp(const unsigned char *s1, const unsigned char *s2, size_t maxlen);

説明

大文字と小文字を区別しないで,文字列の一部を別の文字列の一部と比較します。

strnicmp は,s1 と s2 の符号付きの比較を最大 maxlen バイトまで実行します。これは,両方の文字列内の文字を先頭から順番に 1 文字ずつ比較し,対応する文字が異なっているか文字列の末尾に到達するまで比較を続けます。比較では,大文字と小文字が区別されません。

strcmpi は,s1(またはその一部)と s2(またはその一部)を比較した結果に基づいて,値(< 0,0,または > 0)を返します。

戻り値

s2 より小さい

< 0

s2 と同じ

== 0

s2 より大きい

> 0





 #include <string.h>
 #include <stdio.h>
 int main(void)
 {
    char *buf1 = "BBBccc", *buf2 = "bbbccc";
    int ptr;
    ptr = strnicmp(buf2, buf1, 3);
    if (ptr > 0)
       printf("buffer 2 is greater than buffer 1\n");
    if (ptr < 0)
       printf("buffer 2 is less than buffer 1\n");
    if (ptr == 0)
       printf("buffer 2 equals buffer 1\n");
    return 0;
 }



移植性



POSIX Win32 ANSI C ANSI C++

strnicmp

+

_mbsnicmp

+

_wcsnicmp

+