-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strncpy.c
30 lines (27 loc) · 1.13 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rabougue <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/25 21:40:19 by rabougue #+# #+# */
/* Updated: 2016/05/04 09:18:46 by rabougue ### ########.fr */
/* */
/* ************************************************************************** */
#include "./includes/libft.h"
char *ft_strncpy(char *dst, const char *src, size_t n)
{
size_t i;
i = 0;
while (src[i] != '\0' && i < n)
{
if (src[i] == '\0')
dst[i] = '\0';
dst[i] = src[i];
i++;
}
if (i < n)
ft_bzero(dst + i, n - i);
return (dst);
}