pushswap/libft/src/ft_strlcpy.c

31 lines
1.2 KiB
C
Raw Normal View History

2023-03-01 04:36:58 +01:00
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/01 08:22:27 by djonker #+# #+# */
/* Updated: 2023/02/07 00:40:51 by houtworm ### ########.fr */
/* */
/* ************************************************************************** */
#include "../libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
size_t i;
if (dst == NULL || src == NULL)
return (0);
i = ft_strlen((char *)src);
if (i + 1 < dstsize)
ft_memcpy(dst, src, i + 1);
else if (i != 0 && dstsize != 0)
{
ft_memcpy(dst, src, dstsize - 1);
dst[dstsize - 1] = '\0';
}
return (i);
}