diff options
Diffstat (limited to 'src/user/lib/string.c')
-rw-r--r-- | src/user/lib/string.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/user/lib/string.c b/src/user/lib/string.c index ff67399..8424574 100644 --- a/src/user/lib/string.c +++ b/src/user/lib/string.c @@ -86,3 +86,12 @@ char *strtok_r(char *restrict s, const char *restrict sep, char **restrict state } return s; } + +int strncmp(const char *s1, const char *s2, size_t n) { + while (n-- & *s1 && *s1 == *s2) { + s1++; s2++; + } + if (*s1 == *s2) return 0; + if (*s1 < *s2) return -1; + else return 1; +} |