-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
35 lines (32 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
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lbopp <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/05 14:31:57 by lbopp #+# #+# */
/* Updated: 2016/11/14 11:26:11 by lbopp ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
int i;
int travel;
int j;
j = 0;
travel = 0;
while (dst[travel] && travel < (int)size)
{
travel++;
}
i = ft_strlen(dst);
while ((i + j + 1) < (int)size && (i + j) < ((int)ft_strlen(src) + travel))
{
dst[i + j] = src[j];
j++;
}
dst[i + j] = '\0';
return (travel + ft_strlen(src));
}