-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcpy.c
53 lines (45 loc) · 1.38 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
48
49
50
51
52
53
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hicunha- <hicunha-@student.42porto.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/04 00:16:47 by hicunha- #+# #+# */
/* Updated: 2023/10/05 14:12:41 by hicunha- ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dest, const char *src, size_t size)
{
size_t len;
size_t x;
len = 0;
x = 0;
while (src[len] != '\0')
{
len++;
}
if (size != 0)
{
while (x < size - 1 && src[x] != '\0')
{
dest[x] = src[x];
x++;
}
dest[x] = '\0';
}
return (len);
}
/*#include <stdio.h>
int main()
{
char a[] = "123456789";
char b[7];
unsigned int ft_ex;
unsigned int size;
size = 5;
ft_ex = ft_strlcpy(b, a, size);
printf("%s", b);
printf("\n%d", ft_ex);
}*/