-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
54 lines (49 loc) · 1.46 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
45
46
47
48
49
50
51
52
53
54
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mokhan <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/07 18:08:13 by mokhan #+# #+# */
/* Updated: 2023/09/07 18:08:18 by mokhan ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dest, const char *src, size_t dsize)
{
size_t i;
i = 0;
while (*dest && i < dsize)
{
++i;
++dest;
}
while (*src && i + 1 < dsize)
{
*dest = *src;
++dest;
++src;
++i;
}
if (i < dsize)
*dest = 0;
while (*src)
{
++i;
++src;
}
return (i);
}
/*
int main(void)
{
char dest[20] = "Hello, ";
char src[] = "Worrrrlddd!";
size_t size = sizeof(dest);
size_t result = ft_strlcat(dest, src, size);
printf("Concatenated string: %s\n", dest);
printf("Length of concatenated string: %zu\n", result);
return 0;
}
*/