-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
39 lines (36 loc) · 1.33 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
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abouramd <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/07 11:51:13 by abouramd #+# #+# */
/* Updated: 2022/10/24 11:22:28 by abouramd ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t a;
size_t lendest;
size_t lensrc;
a = 0;
lendest = 0;
lensrc = 0;
while (src[lensrc])
lensrc++;
if (dstsize == 0)
return (lensrc);
while (dst[lendest])
lendest++;
if (dstsize < lendest)
return (lensrc + dstsize);
while ((lendest + a + 1 < dstsize) && src[a])
{
dst[lendest + a] = src[a];
a++;
}
dst[lendest + a] = '\0';
return (lendest + lensrc);
}