-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
33 lines (30 loc) · 1.26 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: lenzo-pe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/11 10:49:14 by lenzo-pe #+# #+# */
/* Updated: 2021/04/06 22:35:37 by lenzo-pe ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_string.h"
size_t ft_strlcat(char *dest, const char *src, size_t size)
{
size_t i;
size_t dest_len;
size_t src_len;
i = 0;
dest_len = ft_strlen(dest);
src_len = ft_strlen(src);
if (dest_len >= size)
return (size + src_len);
while (src[i] && (dest_len + i) < (size - 1))
{
dest[dest_len + i] = src[i];
i++;
}
dest[dest_len + i] = '\0';
return (dest_len + src_len);
}