-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
48 lines (44 loc) · 1.48 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: polmarti <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 11:16:17 by polmarti #+# #+# */
/* Updated: 2023/07/19 16:24:35 by polmarti ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dest, char *src, size_t size)
{
size_t i;
size_t x;
size_t destlen;
size_t srclen;
i = 0;
destlen = ft_strlen(dest);
srclen = ft_strlen(src);
x = destlen;
while (src[i] && x < (size - 1) && size > 0)
{
dest[x] = src[i];
i++;
x++;
}
if (!(dest[x] == '\0'))
dest[x] = '\0';
if (size < destlen)
destlen = size;
return (destlen + srclen);
}
//#include <stdio.h>
/*int main(void)
{
char *dest;
dest[0] = '\0';
dest[11] = 'a';
printf("%zu\n", ft_strlcat("pqrstuvwxyz", "", 0));
printf("%zu\n", ft_strlcat(dest, "lorem ipsum", 15));
return 0;
}*/