C语言stricmp()函数:比较两个字符串大小

函数名: stricmp

头文件:

函数原型: int stricmp(const char *str1, const char *str2);

功 能: 比较两个字符串大小,但不区分大小写

参 数: str1和str2为要比较的两个字符串

返回值: str1>str2 返回1;

str1==str2 返回0;

str1

程序例: 比较字符串buf1和字符串buf2的大小,并输出结果

#include

#include

int main(void) {

char *buf1 = "WWW.DOTCPP.COM", *buf2 = "www.dotcpp.com";

int ptr = stricmp(buf2, buf1);

if (ptr > 0) {

printf("buffer 2 is greater than buffer 1\n");

}

if (ptr < 0){

printf("buffer 2 is less than buffer 1\n");

}

if (ptr == 0) {

printf("buffer 2 equals buffer 1\n");

}

return 0;

}

运行结果:

buffer 2 equals buffer 1

随便看看