-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
36 lines (33 loc) · 1.25 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbetz <rbetz@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/29 10:26:58 by rbetz #+# #+# */
/* Updated: 2022/03/31 16:35:36 by rbetz ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t sl;
size_t dl;
size_t i;
size_t j;
sl = ft_strlen(src);
dl = ft_strlen(dst);
i = dl;
j = 0;
if (dl >= dstsize || src == NULL || dst == NULL)
return (dstsize + sl);
while (i < dstsize - 1 && src[j] != '\0')
{
dst[i] = src[j];
i++;
j++;
}
dst[i] = '\0';
return (sl + dl);
}