feat: add ft_strlcpy function

This commit is contained in:
2025-10-04 16:29:07 +02:00
parent b88037b15a
commit 3e543ced2f
2 changed files with 28 additions and 0 deletions

20
ft_strlcpy.c Normal file
View File

@@ -0,0 +1,20 @@
#include "libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
size_t length;
size_t i;
i = 0;
length = ft_strlen(src);
if (dstsize > 0)
{
while (dstsize - 1 > i && src[i])
{
dst[i] = src[i];
i++;
}
dst[i] = '\0';
}
return (length);
}