-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcpy.c
38 lines (34 loc) · 1.31 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kakiba <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/12 00:11:20 by kakiba #+# #+# */
/* Updated: 2022/07/27 14:55:59 by kakiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
size_t i;
i = 0;
while (src[i] != '\0' && i + 1 < dstsize)
{
dst[i] = src[i];
i++;
}
if (dstsize != 0)
dst[i] = '\0';
return (ft_strlen(src));
}
// int main()
// {
// char s[11];
// printf("%ld\n", ft_strlcpy(s, "1234567890", 11));
// printf("%s\n", s);
// char n[10];
// printf("%d\n", strlcpy(n, "abcdefghij", 11));
// printf("%s\n", s);
// }