-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
35 lines (32 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
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mdahlstr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/22 17:22:01 by mdahlstr #+# #+# */
/* Updated: 2024/04/30 15:21:54 by mdahlstr ### ########.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 append_len;
size_t i;
dst_len = ft_strlen(dst);
src_len = ft_strlen(src);
if (size <= dst_len)
return (src_len + size);
append_len = size - dst_len - 1;
i = 0;
while (src[i] != '\0' && i < append_len)
{
dst[dst_len + i] = src[i];
i++;
}
dst[dst_len + i] = '\0';
return (dst_len + src_len);
}