-
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.3 KB
/
Copy pathft_strlcat.c
File metadata and controls
38 lines (35 loc) · 1.3 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: ysoroko <ysoroko@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/17 10:51:55 by ysoroko #+# #+# */
/* Updated: 2020/11/23 14:32:12 by ysoroko ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t j;
char *my_src;
int dst_len;
my_src = (char *)(src);
dst_len = ft_strlen(dst);
i = dst_len;
j = 0;
if (i >= dstsize || dstsize == 0)
{
return (dstsize + ft_strlen(my_src));
}
while (src[j] != '\0' && i < dstsize - 1)
{
dst[i] = my_src[j];
i++;
j++;
}
dst[i] = '\0';
return (dst_len + ft_strlen(my_src));
}