-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
37 lines (34 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rishimot <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/11 02:27:01 by rishimot #+# #+# */
/* Updated: 2020/07/11 15:49:20 by rishimot ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dest, const char *src, size_t size)
{
size_t i;
size_t dest_len;
size_t src_len;
size_t len;
dest_len = ft_strlen(dest);
src_len = ft_strlen(src);
len = dest_len + src_len;
if (size <= dest_len)
return (src_len + size);
while (*dest)
dest++;
i = 0;
while (i < size - dest_len - 1 && src[i])
{
dest[i] = src[i];
i++;
}
dest[i] = '\0';
return (len);
}