mirror of
https://github.com/guezoloic/libft.git
synced 2026-01-25 03:34:16 +00:00
feat: add ft_strlcpy function
This commit is contained in:
20
ft_strlcpy.c
Normal file
20
ft_strlcpy.c
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user