-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
39 lines (36 loc) · 1.34 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: adiaz-be <adiaz-be@student.42malaga.c +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/21 16:37:12 by adiaz-be #+# #+# */
/* Updated: 2022/08/21 16:37:16 by adiaz-be ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t j;
size_t dst_length;
size_t src_length;
src_length = ft_strlen(src);
dst_length = ft_strlen(dst);
j = dst_length;
i = 0;
if (dst_length < dstsize - 1 && dstsize > 0)
{
while (src[i] && dst_length + i < dstsize - 1)
{
dst[j] = src[i];
j++;
i++;
}
dst[j] = '\0';
}
if (dst_length >= dstsize)
dst_length = dstsize;
return (dst_length + src_length);
}