-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
36 lines (33 loc) · 1.32 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: arsobrei <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/19 14:01:48 by arsobrei #+# #+# */
/* Updated: 2023/08/31 11:56:30 by arsobrei ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t dst_index;
size_t src_index;
size_t length;
length = ft_strlen(dst) + ft_strlen(src);
dst_index = ft_strlen(dst);
src_index = 0;
if (size > dst_index)
{
while ((src[src_index]) && (dst_index < size - 1))
{
dst[dst_index] = src[src_index];
dst_index++;
src_index++;
}
dst[dst_index] = '\0';
return (length);
}
return (ft_strlen(src) + size);
}