-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
37 lines (34 loc) · 1.22 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
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cprune <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/28 10:35:17 by cprune #+# #+# */
/* Updated: 2015/12/05 18:27:38 by cprune ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t result;
size_t i;
size_t j;
i = 0;
j = 0;
result = ft_strlen(src);
while (dst[i] && i < size)
i++;
if (size)
{
while (src[j] && i < size - 1)
dst[i++] = src[j++];
}
if (j > 0)
{
dst[i] = '\0';
return (result + (i - j));
}
return (result + i);
}