-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
33 lines (30 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nopereir <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/07 10:39:01 by nopereir #+# #+# */
/* Updated: 2022/06/12 17:42:30 by nopereir ### ########.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 idx;
idx = 0;
dst_len = ft_strlen(dst);
src_len = ft_strlen(src);
if (size <= dst_len)
return (size + src_len);
while (src[idx] && (idx < size - dst_len - 1))
{
dst[idx + dst_len] = src[idx];
idx++;
}
dst[idx + dst_len] = '\0';
return (dst_len + src_len);
}