-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
36 lines (33 loc) · 1.26 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
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adbouras <adbouras@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/10 15:18:36 by adbouras #+# #+# */
/* Updated: 2023/12/26 12:13:19 by adbouras ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t i;
size_t j;
size_t dst_len;
size_t src_len;
dst_len = ft_strlen(dst);
src_len = ft_strlen(src);
j = dst_len;
i = 0;
if (dstsize <= dst_len)
return (dstsize + src_len);
while (src[i] != '\0' && j < dstsize - 1)
{
dst[j] = src[i];
j++;
i++;
}
dst[j] = '\0';
return (dst_len + src_len);
}