-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
38 lines (35 loc) · 1.32 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: javellis <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/19 17:34:17 by javellis #+# #+# */
/* Updated: 2022/07/19 17:34:27 by javellis ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stddef.h>
#include <stdlib.h>
size_t ft_strlcat(char *dest, char *src, size_t size)
{
size_t i;
size_t j;
size_t src_len;
size_t dest_len;
i = 0;
src_len = ft_strlen(src);
dest_len = ft_strlen(dest);
j = dest_len;
if (size == 0 || size <= dest_len)
return (src_len + size);
while (src[i] != '\0' && i < size - dest_len - 1)
{
dest[j] = src[i];
j++;
i++;
}
dest[j] = '\0';
return (src_len + dest_len);
}