aboutsummaryrefslogtreecommitdiff
path: root/ft_substr.c
diff options
context:
space:
mode:
Diffstat (limited to 'ft_substr.c')
-rw-r--r--ft_substr.c30
1 files changed, 30 insertions, 0 deletions
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 <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/10/07 10:16:26 by cacharle #+# #+# */
+/* Updated: 2019/10/07 12:52:43 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+
+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);
+}