-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcat.c
More file actions
55 lines (46 loc) · 1.73 KB
/
ft_strlcat.c
File metadata and controls
55 lines (46 loc) · 1.73 KB
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
45
46
47
48
49
50
51
52
53
54
55
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sanmetol <sanmetol@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/15 19:14:21 by sanmetol #+# #+# */
/* Updated: 2023/05/11 12:48:07 by sanmetol ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t dst_l;
size_t src_l;
dst_l = ft_strlen(dst);
src_l = ft_strlen(src);
if (dstsize == 0)
return (src_l);
if (dst_l >= dstsize)
return (dstsize + src_l);
i = 0;
while (src[i] && i < dstsize - dst_l - 1)
{
dst[i + dst_l] = src[i];
i++;
}
dst[i + dst_l] = '\0';
return (dst_l + src_l);
}
/* int main(void)
{
char src[31] = "rrrrrrrrrrrrrrr";
char dst[31];
printf("dst: %s\nsrc: %s\n", dst, src);
printf("%zu\n", ft_strlcat(dst, src, 31));
printf("dst: %s\nsrc: %s", dst, src);
///////////////FUNCION ORIGINAL/////////////////
char src_s[31] = "rrrrrrrrrrrrrrr";
char dst_s[31];
printf("\n\nFUNCION ORIGINAL\ndst_o: %s\nsrc_o: %s\n", dst_s, src_s);
printf("%zu\n", strlcat(dst_s, src_s, 31));
printf("dst_o: %s\nsrc_o: %s", dst_s, src_s);
} */