-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_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: dbrandao <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/04 03:59:22 by dbrandao #+# #+# */
/* Updated: 2022/07/01 21:06:33 by dbrandao ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t dst_len;
size_t src_len;
size_t i;
char *s;
s = (char *) src;
dst_len = ft_strlen(dst);
src_len = ft_strlen(src);
i = dst_len;
while (i + 1 < size && *s)
{
dst[i] = *s;
s++;
i++;
}
dst[i] = '\0';
if (dst_len >= size)
return (size + src_len);
return (dst_len + src_len);
}