-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strndup.c
24 lines (21 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
24
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strndup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ssalaues <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/24 20:47:43 by ssalaues #+# #+# */
/* Updated: 2017/01/25 16:11:22 by ssalaues ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strndup(const char *s1, size_t n)
{
char *dup;
dup = ft_memalloc(n + 1);
if (!dup)
return (NULL);
ft_strncpy(dup, s1, n);
return (dup);
}