-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcat.c
More file actions
36 lines (33 loc) · 1.3 KB
/
ft_strlcat.c
File metadata and controls
36 lines (33 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tpeters <tpeters@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/26 15:17:37 by tpeters #+# #+# */
/* Updated: 2022/04/08 15:17:19 by tpeters ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
unsigned int dst_len;
unsigned int src_len;
unsigned int i;
dst_len = ft_strlen(dst);
if (dst_len > size)
dst_len = size;
src_len = ft_strlen(src);
i = 0;
if (size > 0 && dst_len < (size - 1))
{
while (src[i] && (i + dst_len) < size - 1)
{
dst[i + dst_len] = src[i];
i++;
}
dst[dst_len + i] = '\0';
}
return (dst_len + src_len);
}