-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
39 lines (36 loc) · 1.27 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: galemair <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/03 16:18:07 by galemair #+# #+# */
/* Updated: 2018/04/03 19:01:57 by galemair ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dest, const char *src, size_t size)
{
size_t i;
size_t j;
size_t dstlen;
size_t srclen;
dstlen = ft_strlen(dest);
srclen = ft_strlen(src);
i = dstlen;
j = 0;
if (size > 0)
{
while (src[j] && i < size - 1)
{
dest[i] = src[j];
i++;
j++;
}
dest[i] = '\0';
}
if (size <= dstlen)
return (srclen + size);
return (dstlen + srclen);
}