-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcpy.c
More file actions
48 lines (39 loc) · 1.55 KB
/
ft_strlcpy.c
File metadata and controls
48 lines (39 loc) · 1.55 KB
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
44
45
46
47
48
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sanmetol <sanmetol@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/15 19:11:59 by sanmetol #+# #+# */
/* Updated: 2023/05/11 13:01:40 by sanmetol ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
size_t i;
i = 0;
while (i < dstsize - 1 && src[i] && dstsize != 0)
{
dst[i] = src[i];
i++;
}
if (dstsize != 0)
dst[i] = '\0';
return (ft_strlen(src));
}
/* int main(void)
{
char src[] = "que tal";
char dst[10];
//printf("dst: %s\nsrc: %s\n", dst, src);
printf("%zu\n", ft_strlcpy(dst, src, 0));
printf("dst: %s\nsrc: %s", dst, src);
//////////FUNCION ORIGINAL///////////
char src_s[] = "que tal";
char dst_s[10];
//printf("\n\nFUNCION ORIGINAL\ndst_o: %s\nsrc_o: %s\n", dst_s, src_s);
printf("\n%zu\n", strlcpy(dst_s, src_s, 0));
printf("dst_o: %s\nsrc_o: %s", dst_s, src_s);
} */