-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcpy.c
35 lines (32 loc) · 1.25 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
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ysoroko <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/17 10:34:29 by ysoroko #+# #+# */
/* Updated: 2020/12/01 14:09:01 by ysoroko ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dest, const char *src, size_t dstsize)
{
size_t i;
size_t src_length;
char *my_src;
my_src = (char *)(src);
src_length = ft_strlen(my_src);
if (dstsize == 0 || dest == 0)
{
return (src_length);
}
i = 0;
while (my_src[i] != '\0' && i < (dstsize - 1))
{
dest[i] = my_src[i];
i++;
}
dest[i] = '\0';
return (src_length);
}