From 6af21e6a4f2251e71353562d5df7f376fdffc270 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Tue, 25 Mar 2025 17:36:52 -0400 Subject: initial checkout from wrc --- lib/strcat.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib/strcat.c (limited to 'lib/strcat.c') diff --git a/lib/strcat.c b/lib/strcat.c new file mode 100644 index 0000000..b0a8726 --- /dev/null +++ b/lib/strcat.c @@ -0,0 +1,38 @@ +/** +** @file strcat.c +** +** @author Numerous CSCI-452 classes +** +** @brief C implementations of common library functions +*/ + +#ifndef STRCAT_SRC_INC +#define STRCAT_SRC_INC + +#include + +#include + +/** +** strcat(dst,src) - append one string to another +** +** @param dst The destination buffer +** @param src The source buffer +** +** @return The dst parameter +** +** NOTE: assumes dst is large enough to hold the resulting string +*/ +char *strcat( register char *dst, register const char *src ) { + register char *tmp = dst; + + while( *dst ) // find the NUL + ++dst; + + while( (*dst++ = *src++) ) // append the src string + ; + + return( tmp ); +} + +#endif -- cgit v1.2.3-freya