]> pd.if.org Git - pdclib/blobdiff - functions/string/strncpy.c
Merged PDPCLIB and Therx code.
[pdclib] / functions / string / strncpy.c
index 2d865d782b7f0601798aa0b84ba600a6d65fe1ff..fd6e5d26b14fac318eacaf63ea17cca845755ca3 100644 (file)
@@ -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