-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
32 lines (29 loc) · 1.28 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
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_strlcat.c :+: :+: */
/* +:+ */
/* By: splattje <[email protected]> +#+ */
/* +#+ */
/* Created: 2023/10/23 17:25:03 by splattje #+# #+# */
/* Updated: 2023/10/24 08:50:21 by splattje ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t index;
size_t dst_index;
dst_index = 0;
while (dst[dst_index] != '\0' && dst_index < size)
dst_index++;
index = dst_index;
while (src[dst_index - index] && dst_index + 1 < size)
{
dst[dst_index] = src[dst_index - index];
dst_index++;
}
if (index < size)
dst[dst_index] = '\0';
return (index + ft_strlen(src));
}