-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
41 lines (38 loc) · 1.29 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: ssalaues <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 13:52:34 by ssalaues #+# #+# */
/* Updated: 2016/12/12 17:07:07 by ssalaues ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
char *d;
char const *s;
size_t size2;
size_t dsize;
d = dst;
s = src;
size2 = size;
while (*d != '\0' && size2-- != 0)
d++;
dsize = d - dst;
if ((size2 = size - dsize) == 0)
return (dsize + ft_strlen(s));
while (*s != '\0')
{
if (size2 != 1)
{
*d++ = *s;
size2--;
}
s++;
}
*d = '\0';
return (dsize + (s - src));
}