-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
44 lines (38 loc) · 1.37 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: juhtoo-h <juhtoo-h@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/26 14:25:18 by juhtoo-h #+# #+# */
/* Updated: 2024/08/30 09:22:22 by juhtoo-h ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdio.h>
size_t ft_strlcat(char *dest, const char *src, size_t size)
{
size_t i;
size_t j;
i = 0;
j = 0;
while (dest[i] && i < size)
i++;
while (src[j] && (i + j + 1) < size)
{
dest[i + j] = src[j];
j++;
}
if (i < size)
dest[i + j] = '\0';
return (i + ft_strlen(src));
}
// #include <bsd/string.h>
// int main(void)
// {
// char dest[20] = "hippopotamus";
// char src[5] = "yayay";
// printf("%zu\n", strlcat(dest, src, 3));
// printf("%s\n", dest);
// }