-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcpy.c
36 lines (33 loc) · 1.26 KB
/
ft_strlcpy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sonyacorcoran <sonyacorcoran@student.42 +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/21 13:58:09 by sonyacorcor #+# #+# */
/* Updated: 2023/08/21 14:02:34 by sonyacorcor ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t src_len;
i = 0;
if (!dst || !src)
return (0);
src_len = ft_strlen(src);
if (!dstsize)
return (src_len);
while (src[i] != '\0' && i < dstsize)
{
dst[i] = src[i];
i++;
}
if (dstsize < src_len)
dst[dstsize - 1] = '\0';
else if (dstsize != 0)
dst[i] = '\0';
return (src_len);
}