-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcpy.c
47 lines (42 loc) · 1.4 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
44
45
46
47
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: estettle <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/11 11:48:10 by estettle #+# #+# */
/* Updated: 2024/10/11 11:48:11 by estettle ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/* ft_strlcpy()
* copies dstsize chars from *src to *dst, then returns the size of src.
*/
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
size_t i;
i = 0;
if (dstsize > 0)
{
while (i < dstsize - 1 && src[i])
{
dst[i] = src[i];
i++;
}
dst[i] = '\0';
}
return (ft_strlen(src));
}
/*
#include <string.h>
int main(void)
{
char *melody = malloc(100);
char *roxy = malloc(100);
ft_strlcpy(melody, "", 19);
strlcpy(roxy, "", 19);
ft_putstr_fd(melody, 1);
ft_putstr_fd(roxy, 1);
}
*/