-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
35 lines (32 loc) · 1.21 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: badriano <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/17 09:26:38 by badriano #+# #+# */
/* Updated: 2024/05/17 09:50:08 by badriano ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t d;
size_t s;
d = ft_strlen(dst);
s = ft_strlen((char *)src);
i = 0;
if (dstsize <= d)
{
return (dstsize + s);
}
while (src[i] != '\0' && d + i + 1 < dstsize)
{
dst[d + i] = src[i];
i++;
}
dst[d + i] = '\0';
return (d + s);
}