-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strncpy.c
33 lines (30 loc) · 1.12 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alaulom <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/04 15:23:48 by alaulom #+# #+# */
/* Updated: 2016/01/28 13:56:42 by alaulom ### ########.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <string.h>
char *ft_strncpy(char *dst, char *src, size_t n)
{
size_t l;
size_t a;
l = ft_strlen(src);
a = 0;
while (n > 0)
if (l < n)
dst[a] = 0;
else
{
dst[a] = src[a];
a++;
n--;
}
return (dst);
}