-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathft_strlcat.c
34 lines (31 loc) · 1.29 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ggane <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/04/24 09:17:42 by ggane #+# #+# */
/* Updated: 2016/04/25 09:02:59 by ggane ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t i;
size_t j;
size_t len_dst;
i = 0;
j = 0;
len_dst = ft_strlen(dst);
while (dst[i] != '\0' && i < size)
i++;
while (src[j] != '\0' && i < size - 1)
dst[i++] = src[j++];
if (size != 0 && size >= len_dst)
dst[i] = '\0';
if (size < ft_strlen(dst))
return (ft_strlen(src) + size);
else
return (ft_strlen(src) + len_dst);
}