-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
37 lines (34 loc) · 1.29 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: melkholy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/24 22:06:53 by melkholy #+# #+# */
/* Updated: 2022/02/09 15:47:23 by melkholy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t n)
{
size_t count_d;
size_t count_s;
size_t dst_len;
count_s = 0;
count_d = ft_strlen(dst);
dst_len = count_d;
if (n <= dst_len)
return (n + ft_strlen(src));
while (src[count_s] != '\0')
{
if (count_d < (n - 1))
{
dst[count_d] = src[count_s];
count_d ++;
}
count_s ++;
}
dst[count_d] = '\0';
return (dst_len + count_s);
}