-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strncpy.c
executable file
·37 lines (33 loc) · 1.22 KB
/
ft_strncpy.c
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
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mwilliam <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/02 10:46:56 by mwilliam #+# #+# */
/* Updated: 2016/12/02 10:47:02 by mwilliam ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
** Copies len bytes of the NULL-terminated string src to dst
*/
char *ft_strncpy(char *dst, const char *src, size_t len)
{
char *dst2;
size_t index;
index = 0;
dst2 = dst;
while (index < len && src[index])
{
dst2[index] = src[index];
index++;
}
while (index < len)
{
dst2[index] = '\0';
index++;
}
return (dst);
}