-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
33 lines (30 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dvan-der <dvan-der@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/15 08:21:39 by dvan-der #+# #+# */
/* Updated: 2021/12/15 08:21:40 by dvan-der ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t n)
{
size_t i;
size_t dstlen;
size_t srclen;
i = 0;
dstlen = ft_strlen(dst);
srclen = ft_strlen(src);
if (!n || dstlen >= n)
return (srclen + n);
while (src[i] && i < n - dstlen - 1)
{
dst[dstlen + i] = src[i];
i++;
}
dst[dstlen + i] = '\0';
return (srclen + dstlen);
}