-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strncpy.c
26 lines (23 loc) · 1.1 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: asoptere <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/01/24 14:12:22 by asoptere #+# #+# */
/* Updated: 2018/01/24 18:47:35 by asoptere ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncpy(char *dst, const char *src, size_t len)
{
size_t i;
i = 0;
while (*(src + i++) && i - 1 < len)
*(dst + i - 1) = *(src + i - 1);
i--;
while (i++ < len)
*(dst + i - 1) = '\0';
return (dst);
}