stricmp,_mbsicmp,_wcsicmp

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

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


ヘッダーファイル

string.h, mbstring.h

カテゴリ

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

プロトタイプ

int stricmp(const char *s1, const char *s2);

int _wcsicmp(const wchar_t *s1, const wchar_t *s2);

int _mbsicmp(const unsigned char *s1, const unsigned char *s2);

説明

1 つの文字を別の文字と比較します。大文字と小文字は区別されません。

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

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

stricmp と strcmpi は同じルーチンです。strcmpi は,strcmpi の呼び出しを stricmp に変換するマクロとして string.h で実装されています。したがって,stricmp を使用するには,ヘッダーファイル string.h をインクルードして,このマクロを使用できるようにする必要があります。

戻り値

s2 より小さい

< 0

s2 と同じ

== 0

s2 より大きい

> 0





 #include <string.h>
 #include <stdio.h>
 int main(void)
 {
    char *buf1 = "BBB", *buf2 = "bbb";
    int ptr;
    ptr = stricmp(buf2, buf1);
    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++

stricmp

+

+

+

_mbsicmp

+

_wcsicmp

+