Files
42_INT_01_libft/srcs/ft_strncpy.c
2020-02-10 10:25:04 +01:00

31 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/14 21:18:44 by hulamy #+# #+# */
/* Updated: 2019/03/25 15:24:59 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
/*
** copy n characters from string src to dst including '\0'
** if space remain it's filled zith '\0', and return dst
*/
#include "libft.h"
char *ft_strncpy(char *dest, const char *src, size_t n)
{
size_t i;
i = -1;
while (++i < n && src[i])
dest[i] = src[i];
while (i < n)
dest[i++] = '\0';
return (dest);
}