複製鏈接
請複製以下鏈接發送給好友

strcmpi

鎖定
strcmpi用於比較字符串s1和s2。
中文名
strcmpi
功    能
比較字符串s1和s2
説    明
strcmpi是到stricmp宏定義
用    法
#include

strcmpi功能參數

原型:extern int stricmp(char *s1,char * s2);
用法:#include <string.h>
功能:比較字符串s1和s2,但不區分字母的大小寫。
説明:strcmpi是到stricmp的宏定義,實際未提供此函數。
當s1<s2時,返回值<0
當s1=s2時,返回值=0
當s1>s2時,返回值>0
舉例:
// stricmp.c
#include <syslib.h>
#include <string.h>
int main()
{
    char *s1="Hello, Programmers!";
    char *s2="Hello, programmers!";
    int iRet;
    clrscr();
    iRet=strcmpi(s1,s2);
    if(!iRet)
    {
        printf("s1 and s2 are identical");
    }
    else
    {
        if(iRet<0)
            printf("s1 less than s2");
        else
            printf("s1 greater than s2");
     }
    getchar();
    return 0;
}

strcmpi注意事項

在有些linux系統下沒有該函數的定義,而函數strcasecmp具有類似的功能。