-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
37 lines (34 loc) · 1.23 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: alaulom <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/07 11:04:42 by alaulom #+# #+# */
/* Updated: 2016/02/23 15:05:00 by alaulom ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t n)
{
size_t i;
size_t buff;
size_t len2;
size_t n_ori;
i = 0;
n_ori = n;
len2 = ft_strlen(src);
buff = ft_strlen(dst) + len2;
while (*dst && n)
{
n--;
dst++;
}
if (n == 0)
return (n_ori + len2);
while (src[i] && n-- > 1)
*dst++ = src[i++];
*dst = 0;
return (buff);
}