-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
35 lines (33 loc) · 1.3 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: belkarto <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:51:42 by belkarto #+# #+# */
/* Updated: 2022/10/18 21:36:02 by belkarto ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t j;
size_t len_des;
size_t len_src;
i = 0;
j = 0;
len_des = ft_strlen(dst);
len_src = ft_strlen(src);
if (dstsize == 0 || dstsize <= len_des)
return (len_src + dstsize);
while (src[j] != '\0' && j < dstsize - len_des - 1)
{
dst[i + len_des] = src[j];
i++;
j++;
}
dst[i + len_des] = '\0';
return (len_des + len_src);
}