aboutsummaryrefslogtreecommitdiff
path: root/ft_strncpy.c
diff options
context:
space:
mode:
Diffstat (limited to 'ft_strncpy.c')
-rw-r--r--ft_strncpy.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ft_strncpy.c b/ft_strncpy.c
new file mode 100644
index 0000000..100c813
--- /dev/null
+++ b/ft_strncpy.c
@@ -0,0 +1,16 @@
+#include <string.h>
+
+char *ft_strncpy(char *dest, const char *src, size_t n)
+{
+ size_t i;
+
+ i = 0;
+ while (src[i] && i < n)
+ {
+ dest[i] = src[i];
+ i++;
+ }
+ while (i < n)
+ dest[i++] = '\0';
+ return (dest);
+}