-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strncpy.c
More file actions
35 lines (32 loc) · 1.13 KB
/
ft_strncpy.c
File metadata and controls
35 lines (32 loc) · 1.13 KB
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
27
28
29
30
31
32
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: atilegen <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/03/21 12:28:56 by atilegen #+# #+# */
/* Updated: 2018/03/24 12:33:32 by atilegen ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncpy(char *dst, const char *src, size_t len)
{
size_t i;
char *ret;
ret = dst;
i = 0;
while (src[i] && len)
{
if (!len--)
return (dst);
dst[i] = src[i];
i++;
}
while (len--)
{
dst[i] = 0;
i++;
}
return (ret);
}