-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
32 lines (29 loc) · 1.31 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: yochered <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/25 17:17:28 by yochered #+# #+# */
/* Updated: 2018/10/25 17:17:29 by yochered ### ########.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t dstlength;
size_t srclength;
i = 0;
dstlength = ft_strlen(dst);
srclength = ft_strlen(src);
if (dstsize <= dstlength)
return (srclength + dstsize);
while (dst[i] != '\0' && i < dstsize - 1)
i++;
while (*src && i < dstsize - 1)
dst[i++] = *src++;
dst[i] = '\0';
return (dstlength + srclength);
}