-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcat.c
More file actions
35 lines (32 loc) · 1.32 KB
/
ft_strlcat.c
File metadata and controls
35 lines (32 loc) · 1.32 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ychihab <ychihab@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/30 20:15:09 by ychihab #+# #+# */
/* Updated: 2022/10/24 08:18:46 by ychihab ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
unsigned int i;
unsigned int len_src;
unsigned int len_dst;
i = 0;
len_src = ft_strlen(src);
if (!dst && !dstsize)
return (len_src);
len_dst = ft_strlen(dst);
if (len_dst >= dstsize)
return (len_src + dstsize);
while (dstsize && src[i] && i + len_dst < dstsize - 1)
{
dst[len_dst + i] = src[i];
i++;
}
dst[len_dst + i] = '\0';
return (len_dst + len_src);
}