-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
33 lines (29 loc) · 1.3 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: inwagner <inwagner@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/03 18:10:52 by inwagner #+# #+# */
/* Updated: 2023/06/09 18:38:12 by inwagner ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t len)
{
size_t i;
size_t dlen;
dlen = ft_strlen(dst);
if (len <= dlen)
return (len + ft_strlen(src));
i = -1;
while (dlen + i != len - 1 && src[++i])
dst[dlen + i] = src[i];
dst[dlen + i] = 0;
return (dlen + ft_strlen(src));
}
/*
Concatena no final de `dst` `size - 1` bytes de `src`.
Retorna o tamanho da string que tentou concatenar (dst + src).
*/