-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
33 lines (30 loc) · 1.28 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: chanheki <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/11 12:14:12 by chanheki #+# #+# */
/* Updated: 2022/07/25 21:28:49 by chanheki ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t dstlen;
size_t srclen;
size_t index;
index = 0;
dstlen = ft_strlen(dst);
srclen = ft_strlen(src);
if (dstsize < dstlen + 1)
return (srclen + dstsize);
while (dstlen + index + 1 < dstsize && *src)
{
*(dst + dstlen + index) = *(src + index);
index++;
}
*(dst + dstlen + index) = '\0';
return (dstlen + srclen);
}