-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
39 lines (36 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
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: salecler <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/23 01:00:51 by salecler #+# #+# */
/* Updated: 2022/06/23 17:53:18 by salecler ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t j;
size_t l_dst;
size_t l_src;
l_src = ft_strlen(src);
l_dst = ft_strlen(dst);
if (l_dst >= dstsize)
return (dstsize + l_src);
i = 0;
j = l_dst;
if (dstsize > 0)
{
while (src[i] && l_dst + i < dstsize - 1)
{
dst[j] = src[i];
i++;
j++;
}
dst[j] = 0;
}
return (l_src + l_dst);
}