-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
44 lines (39 loc) · 1.42 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
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yeparra- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/22 11:52:44 by yeparra- #+# #+# */
/* Updated: 2023/11/08 16:26:28 by yeparra- ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *s, const char *ct, size_t n)
{
size_t x;
size_t y;
x = 0;
y = ft_strlen(s);
if (n <= y)
return (n + ft_strlen(ct));
while (ct[x] != '\0' && y + 1 < n)
{
s[y] = ct[x];
y++;
x++;
}
s[y] = '\0';
return (y + ft_strlen(&ct[x]));
}
/*
int main()
{
char dst[20] = "Hello, ";
const char *src = "World!";
size_t lcat = ft_strlcat(dst, src, 20);//concateno con strlcat al destino y la longitud
printf("Contenido del destino: %s\n", dst);
printf("Longitud concatenada: %zu\n", lcat);
return (0);
}*/