tgrekov-libft
HIVE libft Oct 2023
Loading...
Searching...
No Matches
ft_strlcat.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_strlcat.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2023/10/24 17:59:54 by tgrekov #+# #+# */
9
/* Updated: 2023/11/09 20:53:03 by tgrekov ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
20
#include "
libft.h
"
21
34
size_t
ft_strlcat
(
char
*dst,
const
char
*src,
size_t
dstsize)
35
{
36
size_t
src_len;
37
size_t
dst_len;
38
size_t
i;
39
40
src_len =
ft_strlen
(src);
41
if
(!dstsize)
42
return
(src_len);
43
dst_len =
ft_strlen
(dst);
44
if
(dstsize < dst_len)
45
return
(src_len + dstsize);
46
i = 0;
47
while
(src[i] && (i + dst_len + 1) < dstsize)
48
{
49
dst[dst_len + i] = src[i];
50
i++;
51
}
52
dst[dst_len + i] =
'\0'
;
53
return
(src_len + dst_len);
54
}
ft_strlcat
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
Appends at most dstsize - ft_strlen(dst) - 1 characters of string src to the end of string dst.
Definition
ft_strlcat.c:34
ft_strlen
size_t ft_strlen(const char *str)
Get length of str.
Definition
ft_strlen.c:28
libft.h
ft_strlcat.c