-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
executable file
·36 lines (33 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
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jpinyot <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/10 03:09:44 by jpinyot #+# #+# */
/* Updated: 2017/11/17 03:35:42 by jpinyot ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *str, size_t size)
{
size_t d_len;
size_t s_len;
d_len = ft_strlen(dst);
s_len = ft_strlen(str);
if (size <= d_len)
return (size + s_len);
if (s_len < size - d_len)
{
ft_memcpy(dst + d_len, str, s_len);
dst = dst + d_len + s_len;
}
else
{
ft_memcpy(dst + d_len, str, size - d_len - 1);
dst = dst + size - 1;
}
*dst = 0;
return (d_len + s_len);
}