-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
39 lines (36 loc) · 1.29 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
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oelkhiar <oelkhiar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/14 11:28:43 by oelkhiar #+# #+# */
/* Updated: 2022/11/20 12:46:19 by oelkhiar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dest, const char *src, size_t size)
{
size_t i;
size_t j;
size_t len_d;
size_t len_s;
i = 0;
j = 0;
if (!dest && !size)
return (ft_strlen(src));
len_d = ft_strlen(dest);
len_s = ft_strlen(src);
j = len_d;
if (size <= len_d)
return (len_s + size);
while (src[i] && i < size - len_d - 1)
{
dest[j] = src[i];
i++;
j++;
}
dest[j] = '\0';
return (len_d + len_s);
}