strncmp
This commit is contained in:
parent
44781b1eaa
commit
b0c5ef74d2
|
@ -39,9 +39,8 @@ int strcmp(const char *str1, const char *str2)
|
|||
//
|
||||
int strncmp(const char *str1, const char *str2, size_t n)
|
||||
{
|
||||
size_t it = 0;
|
||||
|
||||
while (*str1 == *str2 && *str2 && it < n) str1++, str2++, it++;
|
||||
while (n && *str1 && *str1 == *str2) str1++, str2++, n--;
|
||||
if (!n) return 0;
|
||||
|
||||
return *(uchar *)str1 - *(uchar *)str2;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue