-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
35 lines (32 loc) · 1.31 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: reldahli <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/05 10:58:10 by reldahli #+# #+# */
/* Updated: 2023/12/05 12:47:52 by reldahli ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstmax)
{
size_t len_dst;
size_t i;
size_t len_src;
i = 0;
len_dst = ft_strlen(dst);
len_src = ft_strlen(src);
if (dstmax == 0)
return (dstmax + len_src);
while ((src[i] != '\0') && (i + len_dst < dstmax - 1))
{
dst[len_dst + i] = src[i];
i++;
}
dst[len_dst + i] = '\0';
if (len_dst < dstmax)
return (len_dst + len_src);
return (dstmax + len_src);
}