-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcat.c
More file actions
38 lines (35 loc) · 1.31 KB
/
ft_strlcat.c
File metadata and controls
38 lines (35 loc) · 1.31 KB
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
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sryou <sryou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/06 11:41:20 by sryou #+# #+# */
/* Updated: 2022/05/14 13:56:22 by sryou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t idx;
size_t src_len;
size_t dst_len;
src_len = ft_strlen(src);
dst_len = ft_strlen(dst);
if (dstsize == 0)
return (src_len);
if (dst_len >= dstsize)
return (dstsize + src_len);
idx = dst_len;
dst = dst + dst_len;
while (*src != '\0' && idx + 1 < dstsize)
{
*dst = *src;
dst++;
src++;
idx++;
}
*dst = '\0';
return (dst_len + src_len);
}