diff options
-rw-r--r-- | pk/string.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pk/string.c b/pk/string.c index e896379..0e3911d 100644 --- a/pk/string.c +++ b/pk/string.c @@ -47,12 +47,19 @@ size_t strlen(const char *s) int strcmp(const char* s1, const char* s2) { + return strncmp(s1, s2, -1); +} + +int strncmp(const char *s1, const char *s2, size_t n) +{ unsigned char c1, c2; + int i = 0; do { c1 = *s1++; c2 = *s2++; - } while (c1 != 0 && c1 == c2); + i++; + } while (c1 != 0 && c1 == c2 && (n == -1 || i < n)); return c1 - c2; } |