-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strncpy.c
37 lines (34 loc) · 1.17 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abackman <abackman@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/02 17:24:07 by abackman #+# #+# */
/* Updated: 2021/11/25 16:00:03 by abackman ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncpy(char *dst, const char *src, size_t len)
{
size_t i;
size_t j;
i = ft_strlen(src);
j = 0;
while (j < len)
{
if (src[j] == '\0')
{
dst[j] = '\0';
break ;
}
dst[j] = src[j];
j++;
}
if (i < len)
{
ft_bzero((dst + j), (len - i));
}
return (dst);
}