42_libft/ft_strlcpy.c

29 lines
1.1 KiB
C
Raw Permalink Normal View History

2022-09-27 10:29:23 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/27 16:24:15 by cchauvet #+# #+# */
2022-10-04 08:21:55 -04:00
/* Updated: 2022/09/28 17:23:27 by cchauvet ### ########.fr */
2022-09-27 10:29:23 -04:00
/* */
/* ************************************************************************** */
#include "libft.h"
2022-10-04 08:21:55 -04:00
size_t ft_strlcpy(char *dst, const char *src, size_t size)
2022-09-27 10:29:23 -04:00
{
size_t i;
i = 0;
2022-10-04 08:21:55 -04:00
while (i + 1 < size && src[i])
2022-09-27 10:29:23 -04:00
{
dst[i] = src[i];
i++;
}
2022-10-04 08:21:55 -04:00
if (size)
dst[i] = 0;
return (ft_strlen(src));
2022-09-27 10:29:23 -04:00
}