diff options
author | marvinborner | 2019-09-18 11:03:36 +0200 |
---|---|---|
committer | marvinborner | 2019-09-18 11:03:36 +0200 |
commit | c33bc6864a3291dc72b2da071e52e481573f5459 (patch) | |
tree | 2b564a8b874d97acc9faa0308322496a88c9e5bf /src/lib | |
parent | 8e0c4dc52871e720f793db0b21e1b4f504cefcf9 (diff) |
Added missing components
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/lib.h | 8 | ||||
-rw-r--r-- | src/lib/string.c | 14 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/lib.h b/src/lib/lib.h new file mode 100644 index 0000000..aa5d3bc --- /dev/null +++ b/src/lib/lib.h @@ -0,0 +1,8 @@ +#ifndef MELVIX_LIB_H +#define MELVIX_LIB_H + +size_t strlen(const char *str); + +size_t strcmp(const char *s1, const char *s2); + +#endif diff --git a/src/lib/string.c b/src/lib/string.c new file mode 100644 index 0000000..a4be160 --- /dev/null +++ b/src/lib/string.c @@ -0,0 +1,14 @@ +size_t strlen(const char *str) { + size_t len = 0; + while (str[len]) + len++; + return len; +} + +size_t strcmp(const char *s1, const char *s2) { + while (*s1 && (*s1 == *s2)) { + s1++; + s2++; + } + return *(const unsigned char*)s1 - *(const unsigned char*)s2; +} |