-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcat.c
More file actions
39 lines (36 loc) · 1.3 KB
/
ft_strlcat.c
File metadata and controls
39 lines (36 loc) · 1.3 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ophuong <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/09 10:19:20 by ophuong #+# #+# */
/* Updated: 2019/09/10 18:47:02 by ophuong ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t id;
size_t od;
size_t len;
id = 0;
while (dst[id] != '\0' && id < size)
{
id++;
}
len = id;
od = 0;
if (size == 0)
return (ft_strlen(src) + len);
while (src[od] != '\0' && id < size - 1)
{
dst[id] = src[od];
id++;
od++;
}
if (id > size || src[od] == '\0' || id + 1 == size)
dst[id] = '\0';
return (ft_strlen(src) + len);
}