-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strndup.c
25 lines (22 loc) · 1.15 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
25
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_strndup.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: cgarrot <[email protected]> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/10/14 18:35:22 by cgarrot #+# ## ## #+# */
/* Updated: 2018/10/14 18:37:12 by cgarrot ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "libft.h"
char *ft_strndup(const char *s1, size_t len)
{
char *dup;
if (!(dup = (char*)malloc(sizeof(char) * len + 1)))
return (0);
else
dup = ft_strncpy(dup, s1, len);
return (dup);
}