-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strncpy.c
31 lines (28 loc) · 1.08 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: amatshiy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/05/23 15:33:56 by amatshiy #+# #+# */
/* Updated: 2017/06/09 00:08:09 by amatshiy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncpy(char *s1, const char *s2, size_t n)
{
char *s;
s = s1;
while (n > 0 && *s2 != '\0')
{
*s++ = *s2++;
n--;
}
while (n > 0)
{
*s++ = '\0';
n--;
}
return (s1);
}