-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
35 lines (33 loc) · 1.23 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pmaimait <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/09 15:53:10 by pmaimait #+# #+# */
/* Updated: 2022/05/16 13:50:32 by pmaimait ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t i;
size_t j;
size_t len_d;
size_t len_s;
i = ft_strlen(dst);
j = 0;
len_d = ft_strlen(dst);
len_s = ft_strlen(src);
if (size <= len_d)
return (len_s + size);
while (src[j] && i < size - 1)
{
dst[i] = src[j];
i++;
j++;
}
dst[i] = '\0';
return (len_d + len_s);
}