From 8adeef1b50a3a819cf6525af94f1fbce62465a7e Mon Sep 17 00:00:00 2001 From: Cabergs Charles Date: Mon, 7 Oct 2019 16:33:51 +0200 Subject: Added calloc and strlcpy, rename out of date --- ft_substr.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ft_substr.c (limited to 'ft_substr.c') diff --git a/ft_substr.c b/ft_substr.c new file mode 100644 index 0000000..7f7d3c4 --- /dev/null +++ b/ft_substr.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strsub.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/10/07 10:16:26 by cacharle #+# #+# */ +/* Updated: 2019/10/07 12:52:43 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +char *ft_substr(char const *s, unsigned int start, size_t len) +{ + unsigned int i; + char *sub; + + if ((sub = (char*)malloc(sizeof(char) * (len + 1))) == NULL) + return (NULL); + i = 0; + while (i < len) + { + sub[i] = s[start + i]; + i++; + } + sub[i] = '\0'; + return (sub); +} -- cgit