X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrcat.c;h=dfbc135aa15df56e66784e7074cee8df676a82cb;hb=fedb223525324e7ce171f5fe6903430fbd9557bb;hp=a0cef0e04267c24607c14e48394f7cadbcb036e7;hpb=0a5395faab237ba9008352b0f4bee9659bbd3d5f;p=pdclib diff --git a/functions/string/strcat.c b/functions/string/strcat.c index a0cef0e..dfbc135 100644 --- a/functions/string/strcat.c +++ b/functions/string/strcat.c @@ -5,32 +5,19 @@ // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -char * strcat( char * restrict s1, const char * restrict s2 ) { /* TODO */ }; - -/* Therx code +char * strcat( char * restrict dest, const char * restrict src ) { - while (*s1) + char * dest_p = dest; + if ( *dest_p != '\0' ) { - s1++; + while ( *++dest_p != '\0' ) + { + // EMPTY + } } - while (*s1++ = *s2++) + while ( (*dest_p++ = *src++) != '\0' ) { // EMPTY } - return s1; -} -*/ - -/* PDPC code - unreviewed -{ - char *p = s1; - - while (*p != '\0') p++; - while ((*p = *s2) != '\0') - { - p++; - s2++; - } - return (s1); + return dest; } -*/