1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
42-2nd-piscine/finish/C02/ex10/ft_strlcpy.c
2023-08-03 23:16:27 +02:00

39 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/18 13:39:08 by adjoly #+# #+# */
/* Updated: 2023/07/18 19:49:31 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
unsigned int ft_strlcpy(char *dest, char *src, unsigned int size)
{
unsigned int i;
i = 0;
if (size == 0)
{
while (src[i])
i++;
return (i);
}
while (src[i] && i + 1 < size)
{
dest[i] = src[i];
i++;
}
while (i < size)
{
dest[i] = '\0';
i++;
}
i = 0;
while (src[i])
i++;
return (i);
}