-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strncpy.c
More file actions
executable file
·35 lines (32 loc) · 1.21 KB
/
ft_strncpy.c
File metadata and controls
executable file
·35 lines (32 loc) · 1.21 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: anben <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/20 09:03:21 by anben #+# #+# */
/* Updated: 2019/06/02 14:57:06 by anben ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncpy(char *dest, const char *src, size_t len)
{
size_t i;
unsigned char *dpos;
unsigned char *spos;
dpos = (unsigned char *)dest;
spos = (unsigned char *)src;
i = 0;
while (i < len && spos[i] != '\0')
{
dpos[i] = spos[i];
i++;
}
while (i < len)
{
dpos[i] = '\0';
i++;
}
return (dest);
}