-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
33 lines (30 loc) · 1.24 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: youkim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/05/09 11:55:41 by youkim #+# #+# */
/* Updated: 2021/05/09 12:41:11 by youkim ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t dstlen;
size_t srclen;
i = 0;
dstlen = ft_strlen(dst);
srclen = ft_strlen(src);
if (dstsize < dstlen + 1)
return (srclen + dstsize);
while (src[i] && (dstlen + i + 1) < dstsize)
{
dst[dstlen + i] = src[i];
i++;
}
dst[dstlen + i] = 0;
return (srclen + dstlen);
}