-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
33 lines (30 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gaaraujo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/17 21:31:18 by gaaraujo #+# #+# */
/* Updated: 2024/12/07 17:48:13 by gaaraujo ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t src_length;
size_t dst_initial_length;
dst_initial_length = ft_strlen(dst);
src_length = ft_strlen(src);
if (dst_initial_length >= dstsize)
return (src_length + dstsize);
while (*dst)
dst++;
while (*src && dstsize - dst_initial_length - 1 > 0)
{
*dst++ = *src++;
dstsize--;
}
*dst = '\0';
return (src_length + dst_initial_length);
}