函数名:memicmp
头文件:<mem.h>
函数原型: int memicmp(void *s1,void *s2,unsigned m);
功能:比较s1和s2的前m个字节,忽略字符的大写或小写
参数: s1 和 s2 为要比较的字符串
unsigned m 为要比较的前m个字节
返回值:s1>s2 返回1
s1=s2 返回等于0
s1<s2 返回-1
程序例:以忽略大小写的方式比较给定的字符串s1和s2的前6个字符。
#include<stdio.h> #include<mem.h> #include<string.h> int main(void){ char *s1="I love www.dotcpp.com!"; char *s2="I LOVa www.dotcpp.com!"; int t = memicmp(s1,s2,6); if(!t){ printf("s1 is the same as s2\n"); }else if(t>0){ printf("s1 is great than s2\n"); }else{ printf("s1 is less than s2\n"); } return 0; }
运行结果
s1 is the same as s2
本文固定URL:https://www.dotcpp.com/course/493