-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strncpy.c
More file actions
36 lines (33 loc) · 1.19 KB
/
ft_strncpy.c
File metadata and controls
36 lines (33 loc) · 1.19 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
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jagarcia <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/11 01:40:25 by jagarcia #+# #+# */
/* Updated: 2017/11/11 02:07:59 by jagarcia ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncpy(char *dst, const char *src, size_t len)
{
char *dstcpy;
char *srccpy;
dstcpy = dst;
srccpy = (char *)src;
while (len > 0 && *srccpy)
{
*dstcpy++ = *srccpy++;
len--;
}
if (len > 0 && !(*srccpy))
{
while (len > 0)
{
*dstcpy++ = '\0';
len--;
}
}
return (dst);
}