-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
40 lines (37 loc) · 1.28 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
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: imarakho <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/24 13:14:02 by imarakho #+# #+# */
/* Updated: 2016/11/28 19:01:32 by imarakho ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *restrict dst,
const char *restrict src, size_t size)
{
size_t i;
size_t i2;
size_t ln;
if (ft_strlen(dst) < size)
ln = ft_strlen(dst);
else if (ft_strlen(dst) > size)
ln = size;
else
ln = size;
i = 0;
i2 = 0;
while (dst[i])
i++;
while (i < size - 1 && src[i2])
{
dst[i] = src[i2];
i++;
i2++;
}
dst[i] = '\0';
return (ln + ft_strlen(src));
}