From b77ef684b07bcd91c168b15f71611786dd5a3377 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 31 Dec 2019 17:28:49 +0100 Subject: add strcat --- strings.c | 15 +++++++++++++++ strings.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/strings.c b/strings.c index b518388..c741938 100644 --- a/strings.c +++ b/strings.c @@ -106,3 +106,18 @@ void *memset(void *s, int c, size_t n) return s; } +char *strcat(char *dst, const char *src) +{ + char *where_to_append; + + for (where_to_append = dst; *where_to_append; where_to_append++); + + size_t i; + + for (i = 0; src[i]; i++) + ((char volatile*) where_to_append)[i] = src[i]; + + ((char volatile*) where_to_append)[i] = '\0'; + + return dst; +} diff --git a/strings.h b/strings.h index 3c49b7e..aff0533 100644 --- a/strings.h +++ b/strings.h @@ -28,4 +28,6 @@ void memcpy(void *dst, void *src, size_t nbytes); void *memset(void *s, int c, size_t n); +char *strcat(char *dst, const char *src); + #endif // STRINGS_H -- cgit v1.2.3