-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
32 lines (29 loc) · 1.24 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hicunha- <hicunha-@student.42porto.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/04 00:16:29 by hicunha- #+# #+# */
/* Updated: 2023/10/04 00:16:29 by hicunha- ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dest, const char *src, size_t size)
{
size_t c;
size_t d;
c = ft_strlen(dest);
d = 0;
if (size <= ft_strlen(dest))
return (size + ft_strlen(src));
while ((src[d] != '\0') && (c + 1 < size))
{
dest[c] = src[d];
c++;
d++;
}
dest[c] = '\0';
return (ft_strlen(dest) + ft_strlen(&src[d]));
}