-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
32 lines (29 loc) · 1.33 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ebassi <ebassi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/11 17:05:30 by ebassi #+# #+# */
/* Updated: 2022/01/12 15:41:36 by ebassi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
unsigned int index_dest;
unsigned int len_dest;
if (dstsize <= ft_strlen(dst))
return (dstsize + ft_strlen(src));
index_dest = 0;
len_dest = ft_strlen(dst);
while (src[index_dest] != '\0' && len_dest + 1 < (unsigned int)dstsize)
{
dst[len_dest] = src[index_dest];
index_dest++;
len_dest++;
}
dst[len_dest] = '\0';
return (ft_strlen(dst) + ft_strlen(&src[index_dest]));
}