X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstring%2Fstrncpy.c;h=fd6e5d26b14fac318eacaf63ea17cca845755ca3;hp=2d865d782b7f0601798aa0b84ba600a6d65fe1ff;hb=0a5395faab237ba9008352b0f4bee9659bbd3d5f;hpb=34893ecc2200dc7017c36a54cb6c5f4c2378b5ec diff --git a/functions/string/strncpy.c b/functions/string/strncpy.c index 2d865d7..fd6e5d2 100644 --- a/functions/string/strncpy.c +++ b/functions/string/strncpy.c @@ -6,3 +6,24 @@ // ---------------------------------------------------------------------------- char * strncpy( char * restrict s1, const char * restrict s2, size_t n ) { /* TODO */ }; + +/* PDPC code - unreviewed +char *strncpy(char *s1, const char *s2, size_t n) +{ + char *p = s1; + size_t x; + + for (x=0; x < n; x++) + { + *p = *s2; + if (*s2 == '\0') break; + p++; + s2++; + } + for (; x < n; x++) + { + *p++ = '\0'; + } + return (s1); +} +*/ \ No newline at end of file