-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
36 lines (33 loc) · 1.26 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: igilbert <[email protected]. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/24 20:06:17 by ivan #+# #+# */
/* Updated: 2024/11/04 13:13:21 by igilbert ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *restrict dst, const char *restrict src, size_t size)
{
size_t i;
size_t k;
i = 0;
if (size == 0)
return (ft_strlen(src));
k = ft_strlen(dst);
if (k < size - 1 && size > 0)
{
while (src[i] && i + k < size - 1)
{
dst[i + k] = src[i];
i++;
}
dst[i + k] = '\0';
}
if (k >= size)
k = size;
return ((size_t)ft_strlen(src) + k);
}