-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
37 lines (34 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nhennigh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/11 16:35:16 by nhennigh #+# #+# */
/* Updated: 2019/02/14 16:28:45 by nhennigh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t dstlen;
int j;
size_t srclen;
i = ft_strlen(dst);
dstlen = ft_strlen(dst);
j = 0;
srclen = ft_strlen(src);
if (dstsize < dstlen + 1)
return (srclen + dstsize);
if (dstsize > dstlen + 1)
{
while (i < dstsize - 1)
{
*(dst + i++) = *(src + j++);
}
*(dst + i) = '\0';
}
return (dstlen + srclen);
}