-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
37 lines (34 loc) · 1.31 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: abkssiba <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/19 11:31:27 by abkssiba #+# #+# */
/* Updated: 2019/11/02 18:29:47 by abkssiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dest, const char *src, size_t size)
{
size_t len_src;
size_t len_dest;
size_t lend;
int i;
i = 0;
len_src = ft_strlen(src);
if (!dest && size == 0)
return (len_src);
len_dest = ft_strlen(dest);
lend = len_dest;
if (size <= len_dest)
return (size + len_src);
else
{
while (src[i] && lend < size - 1)
dest[lend++] = src[i++];
dest[lend] = '\0';
return (len_dest + len_src);
}
}