-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
34 lines (31 loc) · 1.29 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jbadaire <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/24 14:30:14 by jbadaire #+# #+# */
/* Updated: 2023/01/17 16:41:59 by jbadaire ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t index;
size_t dst_size;
index = 0;
dst_size = ft_strlen(dst);
if (size < dst_size)
return (ft_strlen(src) + size);
if (size <= 0)
return (ft_strlen(src));
while (src[index] && dst_size < size - 1)
{
dst[dst_size] = src[index];
dst_size++;
index++;
}
dst[dst_size] = '\0';
return (dst_size + ft_strlen(&src[index]));
}