-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcat.c
More file actions
42 lines (39 loc) · 1.44 KB
/
ft_strlcat.c
File metadata and controls
42 lines (39 loc) · 1.44 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
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pruthann <pruth@student.21-school.ru> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/14 16:26:53 by pruthann #+# #+# */
/* Updated: 2020/11/15 13:58:27 by pruthann ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
char *temp_dst;
char *temp_src;
unsigned int temp_dstsize;
unsigned int len;
len = ft_strlen(dst) + ft_strlen(src);
temp_dst = dst;
temp_src = (char *)src;
temp_dstsize = dstsize;
if (dstsize < ft_strlen(dst))
return (ft_strlen(src) + dstsize);
while (*temp_dst && temp_dstsize)
{
temp_dst++;
temp_dstsize--;
}
while (*temp_src && temp_dstsize - 1 && temp_dstsize)
{
*temp_dst = *temp_src;
temp_src++;
temp_dst++;
temp_dstsize--;
}
*temp_dst = '\0';
return (len);
}