From 507661351ca718c8a3d8213a0a80f994825fc881 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Tue, 29 Oct 2019 12:25:57 +0100 Subject: libft included --- libft/ft_strlcpy.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 libft/ft_strlcpy.c (limited to 'libft/ft_strlcpy.c') diff --git a/libft/ft_strlcpy.c b/libft/ft_strlcpy.c new file mode 100644 index 0000000..bba4263 --- /dev/null +++ b/libft/ft_strlcpy.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* LE - / */ +/* / */ +/* ft_strlcpy.c .:: .:/ . .:: */ +/* +:+:+ +: +: +:+:+ */ +/* By: rbousset +:+ +: +: +:+ */ +/* #+# #+ #+ #+# */ +/* Created: 2019/10/08 20:44:40 by rbousset #+# ## ## #+# */ +/* Updated: 2019/10/13 08:35:51 by rbousset ### #+. /#+ ###.fr */ +/* / */ +/* / */ +/* ************************************************************************** */ + +#include "libft.h" +#include + +size_t + ft_strlcpy(char *dst, const char *src, size_t size) +{ + size_t src_len; + + if (!dst || !src) + return (0); + src_len = ft_strlen(src); + if (src_len + 1 < size) + ft_memcpy(dst, src, src_len + 1); + else if (size != 0) + { + ft_memcpy(dst, src, size - 1); + dst[size - 1] = 0; + } + return (src_len); +} -- cgit v1.2.3