-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
40 lines (37 loc) · 1.3 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
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmita <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/12 17:22:27 by mmita #+# #+# */
/* Updated: 2022/10/12 18:58:38 by mmita ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t i;
size_t dst_len;
size_t src_len;
i = 0;
dst_len = ft_strlen(dst);
src_len = ft_strlen(src);
if (!size)
{
return (src_len);
}
while (src[i] && dst_len + i < size - 1)
{
dst[dst_len + i] = src[i];
i++;
}
dst[dst_len + i] = '\0';
if (dst_len > size)
{
return (src_len + size);
}
return (src_len + dst_len);
}