-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathft_strlcpy.c
30 lines (27 loc) · 1.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ykoh <ykoh@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/03/17 22:37:45 by ykoh #+# #+# */
/* Updated: 2020/10/05 23:48:08 by ykoh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
size_t srcsize;
if (!dst || !src)
return (0);
srcsize = ft_strlen(src);
if (srcsize < dstsize)
ft_memcpy(dst, src, srcsize + 1);
else if (dstsize)
{
ft_memcpy(dst, src, dstsize - 1);
dst[dstsize - 1] = '\0';
}
return (srcsize);
}