cpp不区分大小写比较字符串string

来源:互联网 发布:淘宝客服怎么实名认证 编辑:程序博客网 时间:2024/05/29 08:40
int StrCaseCmp(const string & stra , const string & strb){int aLen = stra.length();int bLen = strb.length();int iRes = 0 , iPos = 0;for (iPos = 0; iPos < aLen && iPos < bLen; ++iPos){iRes = toupper(stra[iPos]) - toupper(strb[iPos]);if (!iRes)return iRes;}if (iPos == aLen && iPos == bLen)return 0;if (iPos < aLen) return 1;if (iPos < bLen) return -1;}

原创粉丝点击