-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
35 lines (32 loc) · 1.27 KB
/
ft_strlcat.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: juchoi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/21 16:04:44 by juchoi #+# #+# */
/* Updated: 2021/01/21 16:04:46 by juchoi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t dst_l;
size_t src_l;
size_t i;
i = 0;
dst_l = ft_strlen(dst);
src_l = ft_strlen(src);
if (dstsize == 0)
return (src_l);
if (dstsize <= dst_l)
return (src_l + dstsize);
while (dst_l + i + 1 < dstsize && src[i])
{
dst[dst_l + i] = src[i];
i++;
}
dst[dst_l + i] = '\0';
return (src_l + dst_l);
}