From ace65b453151845bc361f21f3e5b651c35f9f126 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 22 May 2024 13:00:41 -0400 Subject: massive refactor for mp and organization --- klib/string.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 klib/string.c (limited to 'klib/string.c') diff --git a/klib/string.c b/klib/string.c new file mode 100644 index 0000000..4bb1bad --- /dev/null +++ b/klib/string.c @@ -0,0 +1,16 @@ +#include "string.h" + +size_t strlen(const char *s) { + size_t l = 0; + for(; *s != 0; s++, l++); + return l; +} + +int strcmp(const char *a, const char *b) +{ + size_t i = 0; + for(; a[i] != 0 && b[i] != 0; i++) { + if(a[i] != b[i]) return a[i] - b[i]; + } + return a[i] - b[i]; +} -- cgit v1.2.1