-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcpy.c
executable file
·40 lines (37 loc) · 1.2 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kbensado <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/12/23 18:30:06 by kbensado #+# #+# */
/* Updated: 2015/12/30 17:48:39 by kbensado ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t n)
{
size_t i;
char *s1;
const char *s2;
s1 = dst;
s2 = src;
i = n;
if (i != 0)
{
while (--i != 0)
{
if ((*s1++ = *s2++) == '\0')
break ;
}
}
if (i == 0)
{
if (n != 0)
*s1 = '\0';
while (*s2++)
;
}
return (s2 - src - 1);
}