stricmp
计算机编程语言
stricmp是计算机编程语言的可以比较字符串数组的一个方法或函数,不区分大小写。
特有函数
功能:比较字符串s1和s2,但不区分字母的大小写。
说明:strcmpi是到stricmp的宏定义,实际未提供此函数。
当s1
当s1=s2时,返回值=0
当s1>s2时,返回值>0
举例:
// stricmp.c
#include
#include
main( )
C/C++中,可以用_stricmp等函数处理字符串大小写不敏感问题。
下面是MSDN上的介绍
_stricmp, _wcsicmp, _mbsicmp
Perform a lowercase comparison of strings.
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_t *string2 );
Routine Required Header Compatibility
_stricmp Win 95, Win NT
_wcsicmp or Win 95, Win NT
_mbsicmp Win 95, Win NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
The return value indicates the relation of string1 to string2 as follows.
Return Value Description
< 0 string1 less than string2
0 string1 identical to string2
> 0 string1 greater than string2
On an error, _mbsicmp returns _NLSCMPERROR, which is defined in STRING.H and MBSTRING.H.
Parameters
string1, string2
Null-terminated strings to compare
Remarks
The _stricmp function lexicographically compares lowercase versions of string1 and string2 and returns a value indicating their relationship. _stricmp differs from _stricoll in that the _stricmp comparison is not affected by locale, whereas the _stricoll comparison is according to the LC_COLLATE category of the current locale. For more information on the LC_COLLATE category, see setlocale.
The _strcmpi function is equivalent to _stricmp and is provided for backward compatibility only.
_wcsicmp and _mbsicmp are wide-character and multibyte-character versions of _stricmp. The arguments and return value of _wcsicmp are wide-character strings; those of _mbsicmp are multibyte-character strings. _mbsicmp recognizes multibyte-character sequences according to the current multibyte code page and returns _NLSCMPERROR on an error. (For more information, see Code Pages.) These three functions behave identically otherwise.
_wcsicmp and wcscmp behave identically except that wcscmp does not convert its arguments to lowercase before comparing them. _mbsicmp and _mbscmp behave identically except that _mbscmp does not convert its arguments to lowercase before comparing them.
Generic-Text Routine Mappings
TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tcsicmp _stricmp _mbsicmp _wcsicmp
Example
/* STRCMP.C */
#include
#include
void main( void )
Output
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
String Manipulation Routines
See Also memcmp, _memicmp, strcmp, strcoll Functions, strncmp, _strnicmp, strrchr, _strset, strspn
运行环境
linux下具有相同功能的函数是strcasecmp,包含在头文件strings.h下。
参考资料
最新修订时间:2024-03-30 12:29
目录
概述
特有函数
参考资料