42-archive/42sh/libft/src/str/ft_strncpy.c
2017-03-17 00:05:10 +01:00

31 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/07 10:48:21 by jhalford #+# #+# */
/* Updated: 2016/08/07 10:48:25 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncpy(char *dst, const char *src, size_t len)
{
size_t i;
i = 0;
while (src[i] != '\0' && i < len)
{
dst[i] = src[i];
i++;
}
while (i < len)
{
dst[i] = '\0';
i++;
}
return (dst);
}