-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
40 lines (37 loc) · 1.3 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
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aerrajiy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/12 01:43:39 by aerrajiy #+# #+# */
/* Updated: 2022/10/16 17:50:51 by aerrajiy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
unsigned int i;
unsigned int j;
unsigned int d;
unsigned int s;
i = 0;
j = 0;
s = ft_strlen(src);
if (!dst && dstsize == 0)
return (s);
while (dst[j])
j++;
d = j;
if (dstsize == 0 || dstsize <= d)
return (s + dstsize);
while (src[i] != '\0' && i < dstsize - d - 1)
{
dst[j] = src[i];
i++;
j++;
}
dst[j] = '\0';
return (d + s);
}