2018-05-04 06:21:52 +03:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
int strncmp(const char *s1, const char *s2, size_t n) {
|
2018-10-12 07:10:46 +03:00
|
|
|
if (n == 0) return 0;
|
|
|
|
|
|
|
|
while (n-- && *s1 == *s2) {
|
|
|
|
if (!n || !*s1) break;
|
2018-05-04 06:21:52 +03:00
|
|
|
s1++;
|
|
|
|
s2++;
|
|
|
|
}
|
2018-10-12 07:10:46 +03:00
|
|
|
return (*(unsigned char *)s1) - (*(unsigned char *)s2);
|
2018-05-04 06:21:52 +03:00
|
|
|
}
|