-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
36 lines (33 loc) · 1.25 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: jkwayiba <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/23 10:34:25 by jkwayiba #+# #+# */
/* Updated: 2019/05/27 08:42:18 by jkwayiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dest, char const *src, size_t n)
{
size_t i;
size_t destlen;
size_t srclen;
i = 0;
destlen = ft_strlen(dest);
srclen = ft_strlen(src);
if (n <= destlen)
return (srclen + n);
while ((dest[i] != '\0') && i < (n - 1))
i++;
while (*src && i < (n - 1))
{
dest[i] = *src;
i++;
src++;
}
dest[i] = '\0';
return (destlen + srclen);
}