-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
33 lines (30 loc) · 1.26 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.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tyassine <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 06:56:35 by tyassine #+# #+# */
/* Updated: 2015/12/01 04:15:22 by tyassine ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t lendst;
size_t res;
size_t j;
j = 0;
lendst = ft_strlen(dst) < size ? ft_strlen(dst) : size;
if (lendst == size)
return (size + ft_strlen(src));
res = ft_strlen(src) + lendst;
while (src[j] && j < size - lendst - 1)
{
dst[lendst + j] = src[j];
j++;
}
dst[lendst + j] = '\0';
return (res);
}