-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcpy.c
34 lines (30 loc) · 1.24 KB
/
ft_strlcpy.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nfaust <nfaust@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/09 11:38:54 by nfaust #+# #+# */
/* Updated: 2022/11/09 14:18:36 by nfaust ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static size_t _min(int a, size_t b)
{
size_t acpy;
acpy = (size_t) a;
if (acpy > b)
return (b);
return (acpy);
}
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
if (dstsize)
{
if (dstsize > 1)
ft_memcpy(dst, src, _min(ft_strlen(src), dstsize - 1));
dst[_min(ft_strlen(src), dstsize - 1)] = 0;
}
return (ft_strlen(src));
}