-
Notifications
You must be signed in to change notification settings - Fork 4
/
ft_strlcat.c
31 lines (28 loc) · 1.23 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vbrazhni <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/06/30 16:55:18 by vbrazhni #+# #+# */
/* Updated: 2018/06/30 16:55:20 by vbrazhni ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t dst_len;
size_t result_len;
dst_len = ft_strlen(dst);
result_len = FT_MIN(dstsize, dst_len) + ft_strlen(src);
if (!(dstsize <= dst_len))
{
dst += dst_len;
dstsize -= dst_len;
while (*src && dstsize-- > 1)
*dst++ = *src++;
*dst = '\0';
}
return (result_len);
}