-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcpy.c
42 lines (39 loc) · 1.37 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kyungkim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/15 01:59:21 by kyungkim #+# #+# */
/* Updated: 2024/11/15 19:58:17 by kyungkim ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dest, const char *src, size_t dstsize)
{
int c;
c = 0;
if (dstsize == 0)
return (ft_strlen(src));
while (src[c] && dstsize > 1)
{
dest[c] = src[c];
c++;
dstsize--;
}
dest[c] = '\0';
return (ft_strlen(src));
}
/*
int main(void)
{
char arr[] = "hi42kay";
char arr1[7];
char arr2[7];
printf("%zu\n", strlcpy(arr1, arr, 1));
printf("%s\n", arr1);
printf("%zu\n", ft_strlcpy(arr2, arr, 1));
printf("%s\n", arr2);
}
*/