From 5b653ccffdc33c8774697a93cad0b499b88dca71 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 28 Jul 2019 21:12:28 +0200 Subject: std library function almost done, tested with libft-unit-tests --- ft_strncpy.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 ft_strncpy.c (limited to 'ft_strncpy.c') 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 + +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); +} -- cgit