-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
43 lines (40 loc) · 1.33 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
42
43
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_strlcat.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: thperchi <[email protected]> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/07/09 05:41:03 by thperchi #+# ## ## #+# */
/* Updated: 2018/10/23 11:40:05 by thperchi ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
char *d;
const char *s;
size_t x;
size_t y;
d = dst;
s = src;
x = size;
while (*d != '\0' && x-- != 0)
d++;
y = d - dst;
x = size - y;
if (x == 0)
return (y + ft_strlen(src));
while (*s != '\0')
{
if (x != 1)
{
*d++ = *s;
x--;
}
s++;
}
*d = '\0';
return (y + (s - src));
}