diff options
author | dzwdz | 2021-10-10 15:43:36 +0000 |
---|---|---|
committer | dzwdz | 2021-10-10 15:43:36 +0000 |
commit | e5077ed02c7e617583fe381db77de6e0faac1af6 (patch) | |
tree | b8ce8a2433e8b613c3de6905897b679fadea52db /src/init/stdlib.c | |
parent | e95ab7393a267f15fb7be915efb2538382bbf838 (diff) |
init/stdlib: implement strcmp
Diffstat (limited to 'src/init/stdlib.c')
-rw-r--r-- | src/init/stdlib.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/init/stdlib.c b/src/init/stdlib.c index 4bc90d2..3714324 100644 --- a/src/init/stdlib.c +++ b/src/init/stdlib.c @@ -13,6 +13,17 @@ int memcmp(const void *s1, const void *s2, size_t n) { return 0; } +int strcmp(const char *s1, const char *s2) { + while (*s1) { + if (*s1 != *s2) { + if (*s1 < *s2) return -1; + else return 1; + } + s1++; s2++; + } + return 0; +} + size_t strlen(const char *s) { size_t c = 0; while (*s++) c++; |