-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
37 lines (34 loc) · 1.32 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
36
37
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_strlcat.c :+: :+: */
/* +:+ */
/* By: jvan-hal <[email protected]> +#+ */
/* +#+ */
/* Created: 2022/10/03 18:51:55 by jvan-hal #+# #+# */
/* Updated: 2022/10/21 14:20:47 by jvan-hal ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t srclen;
size_t dstlen;
dstlen = ft_strlen(dst);
srclen = ft_strlen(src);
if (dstsize == 0 || dstsize < dstlen)
return (dstsize + srclen);
i = 0;
dst += dstlen;
while (src[i] && (dstlen + i) < dstsize)
{
*dst = src[i];
++i;
++dst;
}
if ((dstlen + i) == dstsize && dstlen < dstsize)
--dst;
*dst = '\0';
return (srclen + dstlen);
}