strcmp函数实现


int StrCmp( const char des, const char src)
… {

int c;

if (des == NULL || src == NULL)

throw “ NULL point “ ;

int len1 = strlen(des);

int len2 = strlen(src);

if (len1 != len2)
… {

return len1 - len2;
}

while ( des != ‘ /0 ‘ )
… {

if ((c = (
des ++ - * src ++ )) != 0 )
… {

return c;
}
}

return c;
}

测试用例:

1.字符串为AscII串,并且src和des不为空,测试中以src和des长度分类

2.字符串为高AscII串…..

3.字符串为DBCS串

4.字符串中包含DBCS和ASCII

5.src或者des为NULL

6.src和des为””

  • 本文作者: 帐前卒
  • 本文链接: http://chillyc.info/2007/1937921/
  • 版权声明: 本博客所有文章除特别声明外,只能复制超链接地址,且必须注明出处!