-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strncpy.c
executable file
·37 lines (34 loc) · 1.24 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: jraymond <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/11 22:39:39 by jraymond #+# #+# */
/* Updated: 2017/11/16 16:37:05 by jraymond ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncpy(char *dest, const char *src, size_t n)
{
char *bis_dest;
char *bis_src;
bis_src = (char*)src;
bis_dest = dest;
if (n == 0)
return (dest);
while (n != 0 && *bis_src)
{
*bis_dest = *bis_src;
bis_src++;
bis_dest++;
n--;
}
if (*bis_src == '\0' && n != 0)
{
ft_bzero(bis_dest, n);
return (dest);
}
return (dest);
}