-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcpy.c
41 lines (37 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edegraev <edegraev@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/07 16:33:17 by edegraev #+# #+# */
/* Updated: 2023/11/07 11:40:17 by edegraev ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dest, const char *src, size_t size)
{
unsigned int i;
unsigned int j;
i = 0;
j = ft_strlen(src);
if (size != 0)
{
while (src[i] != '\0' && i < size - 1)
{
dest[i] = src[i];
i++;
}
dest[i] = '\0';
}
return (j);
}
// #include <stdio.h>
// int main(void)
// {
// char my_src[] = "salut";
// char my_des[] = "voici une longue chaine de caractere";
// unsigned int i = ft_strlcpy(my_des, my_src, 5);
// printf("%s\nret:%d\n", my_des, i);
// }