-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_strncpy.c
41 lines (38 loc) · 1.24 KB
/
ft_strncpy.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_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vbrazas <vbrazas@student.unit.ua> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/14 14:17:21 by vbrazas #+# #+# */
/* Updated: 2017/11/19 14:54:55 by vbrazas ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncpy(char *dst, const char *src, size_t len)
{
char *d;
const char *s;
if (len != 0)
{
d = dst;
s = src;
if ((*d++ = *s++) == '\0')
{
while (--len != 0)
*d++ = '\0';
return (dst);
}
while (--len != 0)
{
if ((*d++ = *s++) == '\0')
{
while (--len != 0)
*d++ = '\0';
break ;
}
}
}
return (dst);
}