vc中 'strcasecmp' : undeclared identifier

来源:互联网 发布:上网行为监管软件 编辑:程序博客网 时间:2024/05/16 10:06
编译源代码,vc中经常会出现: 'strcasecmp' : undeclared identifier

在vc的string.h中没有包含此函数:自己写个头文件把最下面的代码加进去即可~~~

strcasecmp()函数的作用是:对两个字符串进行比较。该函数将返回下列值:

0 —— 如果字符串相等

<0 —— 如果string1小于string2

>0 —— 如果string1大于string2

其代码可以写为:

/////////////////////////////////////////////////////////////////////////////////////////

int strcasecmp(char *s1, char *s2)
{
while (toupper((unsigned char)*s1) == toupper((unsigned char)*s2++))
if (*s1++ == '\0')
return 0;

return(toupper((unsigned char)*s1) - toupper((unsigned char)*--s2));
}

转载自http://hi.baidu.com/dwj192/item/70044e09b5ab7925a1312d5c

0 0
原创粉丝点击