-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcpy.c
33 lines (30 loc) · 1.22 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lenzo-pe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/09 20:31:05 by lenzo-pe #+# #+# */
/* Updated: 2021/04/22 14:28:54 by lenzo-pe ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_string.h"
size_t ft_strlcpy(char *dest, const char *src, size_t len)
{
size_t srclen;
if (!src)
return (0);
srclen = ft_strlen(src);
if (len == 0)
return (srclen);
if (srclen >= len)
{
ft_memcpy(dest, src, len - 1);
dest[len - 1] = '\0';
return (srclen);
}
ft_memcpy(dest, src, srclen);
dest[srclen] = '\0';
return (srclen);
}