_stricmp, _wcsicmp, _mbsicmp, _stricmp_l, _wcsicmp_l, _mbsicmp_l

대소문자를 구분하지 않는 문자열 비교를 수행합니다.

Important

Windows 런타임에서 실행되는 애플리케이션에서는 _mbsicmp_mbsicmp_l을 사용할 수는 없습니다. 자세한 내용은 유니버설 Windows 플랫폼 앱에서 지원되지 않는 CRT 함수를 참조하세요.

구문

int _stricmp(
   const char *string1,
   const char *string2
);
int _wcsicmp(
   const wchar_t *string1,
   const wchar_t *string2
);
int _mbsicmp(
   const unsigned char *string1,
   const unsigned char *string2
);
int _stricmp_l(
   const char *string1,
   const char *string2,
   _locale_t locale
);
int _wcsicmp_l(
   const wchar_t *string1,
   const wchar_t *string2,
   _locale_t locale
);
int _mbsicmp_l(
   const unsigned char *string1,
   const unsigned char *string2,
   _locale_t locale
);

매개 변수

string1, string2
비교할 Null 종료 문자열입니다.

locale
사용할 로캘입니다.

반환 값

반환 값은 string1에 대한 string2의 관계를 다음과 같이 나타냅니다.

반환 값 설명
< 0 string1string2보다 짧음
0 string1 = string2
> 0 string1 > string2

오류 _mbsicmp_NLSCMPERROR에서 정의되는 <string.h><mbstring.h>및 .

설명

이 함수는 _stricmp 각 문자를 소문자로 변환한 후 비교 string1string2 하고 관계를 나타내는 값을 반환합니다. _stricmp 비교에는 대문자와 소문자를 결정하는 _stricoll만 적용된다는 점에서 _stricmpLC_CTYPE은 서로 다릅니다. _stricoll 함수는 로캘의 LC_CTYPELC_COLLATE 범주 둘 다에 따라 문자열을 비교합니다. 여기에는 대소문자 및 데이터 정렬 순서가 모두 포함됩니다. 범주에 대한 LC_COLLATE 자세한 내용은 범주 및 로캘을 참조 setlocale 하세요. _l 접미사가 없는 이러한 함수의 버전은 로캘 종속 동작에 현재 로캘을 사용합니다. 접미사가 있는 버전은 전달된 로캘을 사용한다는 점만 제외하면 동일합니다. 로캘이 설정되지 않은 경우 C 로캘이 사용됩니다. 자세한 내용은 Locale을 참조하세요.

참고 항목

_stricmp_strcmpi와 같습니다. 이 두 항목은 서로 바꿔 사용할 수 있지만 기본적으로 사용되는 표준은 _stricmp입니다.

_strcmpi 함수는 _stricmp와 같으며 이전 버전과의 호환성을 위해서만 제공됩니다.

_stricmp는 소문자 비교를 수행하므로 예기치 않은 동작이 발생할 수 있습니다.

대/소문자 변환이 _stricmp 비교 결과에 영향을 주는 경우를 설명하기 위해 두 문자열 JOHNSTONJOHN_HENRY. 문자열 JOHN_HENRY 은 "_"가 소문자 S보다 낮은 ASCII 값을 가지고 있기 때문에 보다 JOHNSTON 작게 간주됩니다. 실제로 ASCII 값이 91에서 96 사이인 문자는 문자보다 작은 것으로 간주됩니다.

함수가 strcmp 대신 _stricmp사용되는 경우 . JOHN_HENRYJOHNSTON

_wcsicmp_mbsicmp_stricmp의 와이드 문자 및 멀티바이트 문자 버전입니다. 인수 및 반환 값 _wcsicmp 은 와이드 문자열입니다. 인수 및 반환 값 _mbsicmp 은 멀티바이트 문자열입니다. _mbsicmp는 현재 멀티바이트 코드 페이지에 따라 멀티바이트 문자 시퀀스를 인식하며 오류 발생 시 _NLSCMPERROR를 반환합니다. 자세한 내용은 코드 페이지를 참조 하세요. 그렇지 않으면 이들 세 함수는 동일하게 작동합니다.

_wcsicmp 비교 wcscmp 하기 전에 인수를 wcscmp 소문자로 변환하지 않는다는 점을 제외하고 동일하게 동작합니다. _mbsicmp 비교 _mbscmp 하기 전에 인수를 _mbscmp 소문자로 변환하지 않는다는 점을 제외하고 동일하게 동작합니다.

라틴 문자 1자를 사용하려면 호출 setlocale_wcsicmp 해야 합니다. C 로캘은 기본적으로 적용되므로 예를 들어 ä는 Ä와 비교하지 않습니다. setlocale를 호출하기 전에 C 이외의 로캘로 _wcsicmp을 호출합니다. 다음 샘플에서는 _wcsicmp가 로캘을 구분하는 방식을 보여 줍니다.

// crt_stricmp_locale.c
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).

#include <string.h>
#include <stdio.h>
#include <locale.h>

int main() {
   setlocale(LC_ALL,"C");   // in effect by default
   printf("\n%d",_wcsicmp(L"ä", L"Ä"));   // compare fails
   setlocale(LC_ALL,"");
   printf("\n%d",_wcsicmp(L"ä", L"Ä"));   // compare succeeds
}

또는 반환된 로캘 개체를 호출_create_locale_wcreate_locale하고 매개 변수로 전달합니다._wcsicmp_l

이러한 모든 함수는 해당 함수 매개 변수의 유효성을 검사합니다. Null 포인터이거나 string1string2 Null 포인터인 경우 매개 변수 유효성 검사에 설명된 대로 잘못된 매개 변수 처리기가 호출됩니다. 계속해서 실행하도록 허용된 경우, 이러한 함수는 _NLSCMPERROR를 반환하고 errnoEINVAL로 설정합니다.

일반 텍스트 루틴 매핑

TCHAR.H 루틴 _UNICODE 정의 _MBCS 되지 않음 _MBCS 정의 _UNICODE 정의
_tcsicmp _stricmp _mbsicmp _wcsicmp

요구 사항

루틴에서 반환된 값 필수 헤더
_stricmp, _stricmp_l <string.h>
_wcsicmp, _wcsicmp_l <string.h> 또는 <wchar.h>
_mbsicmp, _mbsicmp_l <mbstring.h>

호환성에 대한 자세한 내용은 호환성을 참조하세요.

예시

// crt_stricmp.c

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

char string1[] = "The quick brown dog jumps over the lazy fox";
char string2[] = "The QUICK brown dog jumps over the lazy fox";

int main( void )
{
   char tmp[20];
   int result;

   // Case sensitive
   printf( "Compare strings:\n   %s\n   %s\n\n", string1, string2 );
   result = strcmp( string1, string2 );
   if( result > 0 )
      strcpy_s( tmp, _countof(tmp), "greater than" );
   else if( result < 0 )
      strcpy_s( tmp, _countof(tmp), "less than" );
   else
      strcpy_s( tmp, _countof(tmp), "equal to" );
   printf( "   strcmp:   String 1 is %s string 2\n", tmp );

   // Case insensitive (could use equivalent _stricmp)
   result = _stricmp( string1, string2 );
   if( result > 0 )
      strcpy_s( tmp, _countof(tmp), "greater than" );
   else if( result < 0 )
      strcpy_s( tmp, _countof(tmp), "less than" );
   else
      strcpy_s( tmp, _countof(tmp), "equal to" );
   printf( "   _stricmp:  String 1 is %s string 2\n", tmp );
}
Compare strings:
   The quick brown dog jumps over the lazy fox
   The QUICK brown dog jumps over the lazy fox

   strcmp:   String 1 is greater than string 2
   _stricmp:  String 1 is equal to string 2

참고 항목

문자열 조작
memcmp, wmemcmp
_memicmp, _memicmp_l
strcmp, wcscmp, _mbscmp
strcoll 함수
strncmp, wcsncmp, _mbsncmp, _mbsncmp_l
_strnicmp, _wcsnicmp, _mbsnicmp, _strnicmp_l, _wcsnicmp_l, _mbsnicmp_l
strrchr, wcsrchr, _mbsrchr, _mbsrchr_l
_strset, _strset_l, _wcsset, _wcsset_l, _mbsset, _mbsset_l
strspn, wcsspn, _mbsspn, _mbsspn_l