-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
38 lines (35 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
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rjada <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/07 19:47:09 by rjada #+# #+# */
/* Updated: 2021/10/10 19:11:10 by rjada ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stddef.h>
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t j;
size_t dlen;
dlen = ft_strlen(dst);
i = dlen;
j = 0;
if (dlen < dstsize - 1 && dstsize > 0)
{
while (src[j] && dlen + j < dstsize - 1)
{
dst[i] = src[j];
++i;
++j;
}
dst[i] = 0;
}
if (dlen >= dstsize)
dlen = dstsize;
return (dlen + ft_strlen(src));
}