比较字符串不区分大小写
2010-07-19 10:05
204 查看
int compareAb(const char* dst,const char* src){
unsigned char s_tolowerTable[256];
for(int i = 0; i < 256; ++i) //初始化不分大小写的数组
s_tolowerTable[i] = (unsigned char)tolower(i);
//不区分大小写进行比较 知道完全匹配结束 或 中途不匹配结束
for( ; *dst && *src && s_tolowerTable[(unsigned char)(*dst)] == s_tolowerTable[(unsigned char)(*src)]; ++dst, ++src)
;
//返回0 为匹配相等 返回其它值 匹配不相等
return s_tolowerTable[(unsigned char)(*dst)] - s_tolowerTable[(unsigned char)(*src)];
}
unsigned char s_tolowerTable[256];
for(int i = 0; i < 256; ++i) //初始化不分大小写的数组
s_tolowerTable[i] = (unsigned char)tolower(i);
//不区分大小写进行比较 知道完全匹配结束 或 中途不匹配结束
for( ; *dst && *src && s_tolowerTable[(unsigned char)(*dst)] == s_tolowerTable[(unsigned char)(*src)]; ++dst, ++src)
;
//返回0 为匹配相等 返回其它值 匹配不相等
return s_tolowerTable[(unsigned char)(*dst)] - s_tolowerTable[(unsigned char)(*src)];
}
相关文章推荐
- stricmp——不区分大小写比较字符串
- iOS字符串比较(区分与不区分大小写比较)
- CompareText 比较两个字符串的ordinal value,不区分大小写
- JAVA简单实现不区分大小写以及空格比较字符串
- CompareNoCase 比较两个字符串,不区分大小写
- cpp不区分大小写比较字符串string
- C#不区分字母大小写比较字符串
- 比较两个字符串的最长公共子序列的长度,字符不区分大小写
- C语言中库函数不区分大小写比较字符串
- C语言strcmp()函数:比较字符串(区分大小写)
- 比较字符串,不区分大小写
- 面试题题排序,字符串数组按照字母排序,不区分大小写比较
- windows c++ 比较字符串 不区分大小写
- js 不区分大小写比较字符串
- csharp 字符串比较,不区分大小写
- Java 比较两个对象是否相等【含字符串,区分与不区分大小写】
- 细节:字符串比较 之 是否要区分大小写。
- Exceptional C++, 实现一个不区分大小写的字符串比较类
- iOS字符串比较(区分与不区分大小写比较)
- C语言strcmp()函数:比较字符串(区分大小写)