-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_strlcat.c
executable file
·40 lines (37 loc) · 1.33 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rel-fila <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/16 13:22:36 by rel-fila #+# #+# */
/* Updated: 2022/10/16 13:23:11 by rel-fila ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t j;
size_t dst_len;
size_t src_len;
if (dstsize == 0)
return (ft_strlen(src));
i = 0;
j = 0;
dst_len = ft_strlen(dst);
src_len = ft_strlen(src);
if (dstsize <= dst_len)
return (src_len + dstsize);
while (dst[i] != '\0')
i++;
while (src[j] != '\0' && i < dstsize - 1)
{
dst[i] = src[j];
i++;
j++;
}
dst[i] = '\0';
return (dst_len + src_len);
}