first commit
This commit is contained in:
38
finish/C02/ex10/ft_strlcpy.c
Normal file
38
finish/C02/ex10/ft_strlcpy.c
Normal file
@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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);
|
||||
}
|
Reference in New Issue
Block a user