windows API 第八篇 _tcsicmp _stricmp _wcsicmp _mbsicmp


這些函數都是比較字符串小寫的,忽略大寫,出入的字符串都將按照小寫比較
Perform a lowercase comparison of strings.

函數原型:

int _stricmp( const char *string1, const char *string2 );        //#include <string.h>

int _wcsicmp( const wchar_t *string1, const wchar_t *string2 );    //#include <string.h> or  <wchar.h>

int _mbsicmp( const unsigned char *string1, const unsigned char_t *string2 );    //#include <mbstring.h>

返回值:

0: string1 identical to string2         <0:string1 less than  string2             >0:string1 greater than string2

舉例:
char *str1 = "abc";
char *str2 = "AbC";
int  nResult = _stricmp(str1, str2);         //nResult = 0

wchar_t szStr1[] = "asdfg";
wchar_t szStr2[] = "AsDfG";
int nResult = _wcsicmp(szStr1, szStr2);      //nResult = 0

至於_mbsicmp是比較無符號字符串的,可根據情況自行使用


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM