From 75ea20675d012e692996bc6beae9149b0deb08b0 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Fri, 5 Nov 2021 18:52:11 +0100 Subject: initial commit --- stecpy.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 stecpy.c (limited to 'stecpy.c') diff --git a/stecpy.c b/stecpy.c new file mode 100644 index 0000000..02b69c6 --- /dev/null +++ b/stecpy.c @@ -0,0 +1,17 @@ +#include + +char * +stecpy(char *dst, const char *end, const char *src) +{ + if (dst >= end) + return dst; + + size_t n = end - dst; + while (n && (*dst = *src)) + n--, src++, dst++; + + if (dst == end) + dst[-1] = 0; + + return dst; +} -- cgit 1.4.1