-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcpy.c
30 lines (28 loc) · 1.13 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dbrophy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/28 14:00:41 by dbrophy #+# #+# */
/* Updated: 2019/10/28 14:58:24 by dbrophy ### ########.fr */
/* */
/* ************************************************************************** */
unsigned int ft_strlcpy(char *dest, const char *src, unsigned int n)
{
unsigned int out;
unsigned int i;
i = 0;
out = 0;
while (src[out])
out++;
while (src[i] && i + 1 < n)
{
dest[i] = src[i];
i++;
}
if (n != 0)
dest[i] = 0;
return (out);
}