您的位置:首页 > 其它

不同的strcmp

2015-10-23 15:25 141 查看
Android libc中的strcmp
https://android.googlesource.com/platform/bootable/bootloader/legacy/+/donut-release/libc/strcmp.c
int strcmp(const char *a, const char *b)
{
  while(*a && *b) {
  if(*a++ != *b++) return 1;
  }
  if(*a || *b) return 1;
  return 0;
}

ios中libc中的strcmp
http://www.opensource.apple.com/source/Libc/Libc-262/ppc/gen/strcmp.c
int strcmp(const char *s1, const char *s2)
{
  for ( ; *s1 == *s2; s1++, s2++)
  if (*s1 == '\0')
  return 0;
  return ((*(unsigned char *)s1 < *(unsigned char *)s2) ? -1 : +1);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: