-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcpy.c
More file actions
46 lines (43 loc) · 1.41 KB
/
ft_strlcpy.c
File metadata and controls
46 lines (43 loc) · 1.41 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sudaniel <sudaniel@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/09 11:39:03 by sudaniel #+# #+# */
/* Updated: 2024/10/09 16:02:32 by sudaniel ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
size_t srclen;
size_t index;
srclen = ft_strlen(src);
index = 0;
if (dstsize > 0)
{
while (index < dstsize - 1 && src[index])
{
dst[index] = src[index];
index++;
}
dst[index] = '\0';
}
return (srclen);
}
/*
int main(void)
{
char s[] = "Hello, Success";
char d[20];
char d1[20];
size_t n, n1;
n = ft_strlcpy(d, s, sizeof(d));
n1 = strlcpy(d1, s, sizeof(d1));
printf("%zu\n%zu\n", n, n1);
printf("%s\n%s\n", d, d1);
return (0);
}
*/