-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
33 lines (30 loc) · 1.24 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lpires-n <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/02 04:16:03 by lpires-n #+# #+# */
/* Updated: 2022/06/04 06:23:30 by lpires-n ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t i;
size_t len_dst;
size_t len_src;
i = 0;
len_dst = ft_strlen(dst);
len_src = ft_strlen(src);
if (size < len_dst)
return (size + len_src);
while (src[i] && size > (len_dst + 1 + i))
{
dst[len_dst + i] = src[i];
i++;
}
dst[len_dst + i] = '\0';
return (len_src + len_dst);
}