-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
35 lines (32 loc) · 1.32 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: zbenaiss <zbenaiss@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/24 21:12:10 by zbenaiss #+# #+# */
/* Updated: 2022/10/27 07:28:35 by zbenaiss ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t j;
size_t dstlen;
size_t destnow;
i = 0;
j = 0;
if (dstsize == 0)
return (ft_strlen(src));
destnow = ft_strlen(dst);
if (dstsize < destnow)
return (ft_strlen(src) + dstsize);
dstlen = dstsize - destnow - 1;
i = destnow;
while (j < dstlen && i < dstsize && src[j])
dst[i++] = src[j++];
dst[i] = '\0';
return (ft_strlen(src) + destnow);
}