diff options
Diffstat (limited to 'src/str/ft_strndup.c')
| -rw-r--r-- | src/str/ft_strndup.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/str/ft_strndup.c b/src/str/ft_strndup.c new file mode 100644 index 0000000..0683dae --- /dev/null +++ b/src/str/ft_strndup.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strndup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/10/25 03:28:52 by cacharle #+# #+# */ +/* Updated: 2019/11/20 04:15:44 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strndup(const char *s1, size_t n) +{ + char *clone; + + if ((clone = ft_strnew(n)) == NULL) + return (NULL); + return (ft_strncpy(clone, s1, n)); +} |
