-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
41 lines (38 loc) · 1.38 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
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abertran <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 12:52:17 by abertran #+# #+# */
/* Updated: 2022/10/18 15:13:05 by abertran ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/* Copia y concatena strings */
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t c;
size_t d;
if (dstsize == 0 || dstsize <= ft_strlen(dst))
return (dstsize + ft_strlen(src));
c = ft_strlen(dst);
d = 0;
while (src[d] != '\0' && c + 1 < dstsize)
{
dst[c] = src[d];
d++;
c++;
}
dst[c] = '\0';
return (ft_strlen(dst) + ft_strlen(&src[d]));
}
/*
int main(void)
{
char src[] = "hola";
char dst[] = "adios";
printf("%zu", ft_strlcat(dst, src, 3));
}
*/