-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
36 lines (34 loc) · 1.33 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nhan <necat.han42@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/20 14:05:09 by nhan #+# #+# */
/* Updated: 2023/10/23 10:36:07 by nhan ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t dst_len;
size_t src_len;
size_t total_len;
size_t i;
dst_len = ft_strlen(dst);
src_len = ft_strlen(src);
total_len = dst_len + src_len;
i = 0;
if (dstsize == 0 || dstsize <= dst_len)
return (src_len + dstsize);
while (src[i] && dst_len < dstsize - 1)
{
dst[dst_len] = src[i];
dst_len++;
i++;
}
if (dstsize != 0)
dst[dst_len] = '\0';
return (total_len);
}