From 1e9b077e0d9f3c50d7d518bf6ea7f08e7f5ec590 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 15 Jan 2020 10:04:09 +0100 Subject: splited src in category, more generic makefile --- src/str/ft_strndup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/str/ft_strndup.c (limited to 'src/str/ft_strndup.c') 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 +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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)); +} -- cgit