Function name : strcmpi
Header file : <string.h>
Function prototype : int strcmpi(char *str1, char *str2);
Function : Compare the size of two strings, but not case sensitive
Parameters : str1 and str2 are the strings to be compared
Return value : str1>str2 returns 1;
str1==str2 returns 0;
str1<str2 returns -1;
Program example : Compare the strings buf1 and buf2, case-insensitively, and output the result
#include<string.h>#include<stdio.h>intmain(void){char*buf1=www.dotcpp.com,*buf2=WWW.DOTCPP.COM;intptr=strcmpi(buf2,buf1);if(ptr >0){printf(buffer2isgreaterthanbuffer1n);}if(ptr<0){printf(buffer2islessthanbuffer1n);}if(ptr==0){printf(buffer2equalsbuffer1n);}return0;}
Running results:
buffer2equalsbuffer1