-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcat.c
38 lines (35 loc) · 1.22 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: schetty <schetty@student.42kl.edu.my> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/05/07 09:02:16 by schetty #+# #+# */
/* Updated: 2021/11/10 19:02:57 by schetty ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t len;
len = 0;
while (dst[len] && len < size)
len++;
if (len < size)
{
size -= len;
dst += len;
while (*src && --size)
{
*dst++ = *src++;
len++;
}
*dst = '\0';
}
else if (len > size)
len = size;
while (*src++)
len++;
return (len);
}