diff options
Diffstat (limited to 'src/lib/string.c')
-rw-r--r-- | src/lib/string.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/lib/string.c b/src/lib/string.c index a4be160..6ef0316 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -1,3 +1,5 @@ +#include <stddef.h> + size_t strlen(const char *str) { size_t len = 0; while (str[len]) @@ -7,8 +9,19 @@ size_t strlen(const char *str) { size_t strcmp(const char *s1, const char *s2) { while (*s1 && (*s1 == *s2)) { - s1++; - s2++; + s1++; + s2++; + } + return *(const unsigned char *) s1 - *(const unsigned char *) s2; +} + +char *strcat(char *dst, const char *src) { + unsigned int i = 0; + unsigned int j = 0; + for (i = 0; dst[i] != 0; i++) {} + for (j = 0; src[j] != 0; j++) { + dst[i + j] = src[j]; } - return *(const unsigned char*)s1 - *(const unsigned char*)s2; + dst[i + j] = 0; + return dst; } |