-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcpy.c
38 lines (35 loc) · 1.17 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lwilliam <lwilliam@student.42kl.edu.my> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/23 11:15:10 by lwilliam #+# #+# */
/* Updated: 2022/05/27 15:38:32 by lwilliam ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dest, const char *src, size_t y)
{
size_t x;
x = 0;
if (y == 0)
{
while (src[x])
x++;
return (x);
}
while (src[x] != '\0' && x < y - 1)
{
dest[x] = src[x];
x++;
}
if (x < y)
{
dest[x] = '\0';
}
while (src[x] != '\0')
x++;
return (x);
}