-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
33 lines (30 loc) · 1.25 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaraval <tmaraval@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/13 08:27:25 by tmaraval #+# #+# */
/* Updated: 2017/11/20 08:11:22 by tmaraval ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t dstlen;
size_t srclen;
size_t i;
dstlen = ft_strlen(dst);
srclen = ft_strlen(src);
i = 0;
while (src[i] != '\0' && (dstlen + i) < (size - 1) && size != 0)
{
dst[dstlen + i] = src[i];
i++;
}
dst[dstlen + i] = '\0';
if (size < dstlen)
return (srclen + size);
return (dstlen + srclen);
}