summaryrefslogtreecommitdiffstats
path: root/klib/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'klib/string.c')
-rw-r--r--klib/string.c16
1 files changed, 16 insertions, 0 deletions
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];
+}