-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
35 lines (32 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: smurad <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/18 08:00:51 by smurad #+# #+# */
/* Updated: 2019/12/18 08:05:20 by smurad ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *restrict dst, const char *restrict src, size_t dstsize)
{
size_t i;
size_t len;
size_t lendst;
i = 0;
lendst = ft_strlen(dst);
len = ft_strlen(dst) + ft_strlen(src);
if (dstsize <= ft_strlen(dst))
return (ft_strlen(src) + dstsize);
while (*dst)
dst++;
while ((i < (dstsize - lendst - 1)) && src[i])
{
dst[i] = src[i];
i++;
}
dst[i] = '\0';
return (len);
}