-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
45 lines (41 loc) · 1.44 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
40
41
42
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: azaghlou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 10:04:13 by azaghlou #+# #+# */
/* Updated: 2022/10/25 02:50:30 by azaghlou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t j;
size_t x;
if (!dstsize && !dst)
return (0);
i = 0;
x = ft_strlen(src) + ft_strlen(dst);
j = ft_strlen(dst);
if (!dst)
return (ft_strlen(src));
if (dstsize < j || dstsize == 0)
return (dstsize + ft_strlen(src));
while (src[i] != '\0' && j < dstsize - 1)
{
dst[j] = src[i];
i++;
j++;
}
dst[j] = '\0';
return (x);
}
// int main()
// {
// char dst[] = "aptx48";
// char src[] = "chaknannnn";
// printf("--> %zu\n", ft_strlcat(dst, src, 6));
// }