-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
32 lines (29 loc) · 1.17 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bmaaqoul <bmaaqoul@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/05 11:32:21 by bmaaqoul #+# #+# */
/* Updated: 2021/11/12 15:52:14 by bmaaqoul ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t l)
{
size_t i;
size_t j;
size_t k;
size_t cp;
k = 0;
i = ft_strlen(dst);
j = ft_strlen(src);
cp = i;
if (i >= l)
return (j + l);
while (src[k] && cp < l - 1)
dst[cp++] = src[k++];
dst[cp] = '\0';
return (i + j);
}