-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcat.c
executable file
·36 lines (33 loc) · 1.34 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
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/18 16:17:39 by akharrou #+# #+# */
/* Updated: 2019/03/04 13:17:20 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Includes/string_42.h"
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
int bytes_left;
size_t dst_len;
size_t src_len;
unsigned int i;
unsigned int j;
dst_len = ft_strlen(dst);
src_len = ft_strlen(src);
bytes_left = (int)dstsize - dst_len - 1;
if (bytes_left >= 0)
{
i = dst_len;
j = 0;
while (bytes_left-- && src[j])
dst[i++] = src[j++];
dst[i] = '\0';
return (src_len + dst_len);
}
return (src_len + dstsize);
}