-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcpy.c
43 lines (39 loc) · 1.5 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
36
37
38
39
40
41
42
43
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: anamartinez <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/29 19:10:08 by anamart3 #+# #+# */
/* Updated: 2023/05/05 13:53:01 by anamartinez ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
size_t src_length;
size_t i;
src_length = ft_strlen(src);
if (dstsize == 0)
return (src_length);
i = 0;
while (src[i] && i < (dstsize - 1))
{
dst[i] = src[i];
i++;
}
dst[i] = '\0';
return (src_length);
}
// int main(void)
// {
// char dst[50] = "";
// char src[] = "aaa";
// char dst1[50] = "";
// printf("Oficcial function return: %lu\n", strlcpy(dst, src, 0));
// printf("Official function dst: %s\n", dst);
// printf("My function return: %lu\n", ft_strlcpy(dst1, src, 0));
// printf("My function dst: %s\n", dst1);
// return (0);
// }