-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
33 lines (30 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: malexand <malexand@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/06/26 18:02:30 by root #+# #+# */
/* Updated: 2017/02/16 17:33:41 by malexand ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dest, const char *src, size_t size)
{
size_t i;
size_t destlen;
size_t srclen;
destlen = ft_strlen(dest);
srclen = ft_strlen(src);
if (size < destlen)
return (size + srclen);
i = 0;
while (src[i] != '\0' && (destlen + i + 1) < size)
{
dest[destlen + i] = src[i];
i++;
}
dest[destlen + i] = '\0';
return (destlen + srclen);
}