-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
41 lines (38 loc) · 1.22 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
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bcaffere <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/04/24 19:35:03 by bcaffere #+# #+# */
/* Updated: 2021/04/30 22:40:58 by bcaffere ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dest, const char *src, size_t n)
{
size_t size;
size_t i;
size_t len;
size = 0;
i = 0;
len = ft_strlen(src);
while (dest[i] && n > 0)
{
i++;
size++;
n--;
}
if (n < 1)
return (size + len);
while (*src && n > 1)
{
dest[i] = *src;
i++;
src++;
n--;
}
dest[i] = '\0';
return (size + len);
}