libft
ft_strncpy.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* ft_strncpy.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2019/09/04 23:00:30 by unite #+# #+# */
10 /* Updated: 2020/07/16 02:42:41 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "libft.h"
15 
20 char *ft_strncpy(char *dst, const char *src, size_t len)
21 {
22  size_t i;
23 
24  i = 0;
25  while (i < len && src[i])
26  {
27  dst[i] = src[i];
28  i++;
29  }
30  while (i < len)
31  {
32  dst[i] = '\0';
33  i++;
34  }
35  return (dst);
36 }
libft.h
ft_strncpy
char * ft_strncpy(char *dst, const char *src, size_t len)
Replicates behaviour of strncpy from libc.
Definition: ft_strncpy.c:20