34 lines
1.1 KiB
C
34 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strlcpy.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: pbonilla <eirodeis.lepnj@gmail.com> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2020/11/08 17:09:59 by pbonilla #+# #+# */
|
|
/* Updated: 2020/11/11 21:38:14 by pbonilla ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
size_t ft_strlcpy(char *dst, const char *src, size_t size)
|
|
{
|
|
size_t i;
|
|
size_t j;
|
|
|
|
if (!dst)
|
|
return (0);
|
|
i = ft_strlen(src);
|
|
if (size == 0)
|
|
return (i);
|
|
j = 0;
|
|
while (j < i && j < size - 1)
|
|
{
|
|
dst[j] = src[j];
|
|
++j;
|
|
}
|
|
dst[j] = 0;
|
|
return (i);
|
|
}
|