42-archive/42-piscine-c/d05/ex04/ft_strncpy.c
2016-08-25 20:50:28 +02:00

29 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 */
/* */
/* ************************************************************************** */
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
int i;
i = 0;
while (src[i] != '\0' && i < (int)n)
{
dest[i] = src[i];
i++;
}
while (i < (int)n)
{
dest[i] = '\0';
i++;
}
return (dest);
}