-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strndup.c
23 lines (20 loc) · 1.04 KB
/
ft_strndup.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strndup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ybitton <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/16 16:34:04 by ybitton #+# #+# */
/* Updated: 2016/12/16 16:35:57 by ybitton ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strndup(const char *s1, size_t n)
{
char *tmp;
if (!(tmp = ft_strnew(n)))
return (NULL);
ft_strncpy(tmp, s1, n);
return (tmp);
}