-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
38 lines (35 loc) · 1.21 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: luiroel <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/08 15:14:51 by luiroel #+# #+# */
/* Updated: 2020/02/26 21:17:43 by luiroel ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t srclen;
size_t len;
len = 0;
srclen = ft_strlen((char *)src);
while (*dst && size > 0)
{
dst++;
len++;
size--;
}
while (*src && size > 1)
{
*dst++ = *src++;
size--;
}
if (size == 1 || *src == 0)
{
*dst = '\0';
}
return (srclen + len);
}