summaryrefslogtreecommitdiffstats
path: root/libft
diff options
context:
space:
mode:
Diffstat (limited to 'libft')
-rw-r--r--libft/Makefile1
-rw-r--r--libft/include/libft.h2
-rw-r--r--libft/src/ft_substr_s.c18
3 files changed, 21 insertions, 0 deletions
diff --git a/libft/Makefile b/libft/Makefile
index 5498983..4024b3e 100644
--- a/libft/Makefile
+++ b/libft/Makefile
@@ -48,6 +48,7 @@ SRCS_NAME += ft_calloc.c
SRCS_NAME += ft_nrealloc.c
SRCS_NAME += ft_strdup.c
SRCS_NAME += ft_substr.c
+SRCS_NAME += ft_substr_s.c
SRCS_NAME += ft_strjoin.c
SRCS_NAME += ft_strtrim.c
SRCS_NAME += ft_split.c
diff --git a/libft/include/libft.h b/libft/include/libft.h
index def0a31..47992c0 100644
--- a/libft/include/libft.h
+++ b/libft/include/libft.h
@@ -91,6 +91,8 @@ void ft_memdel(void **ptr);
void ft_delwords(char **words);
void ft_itoa_s(char str[], long n);
void ft_uitoa_s(char str[], unsigned long n);
+void ft_substr_s(char str[], const char *s,
+ unsigned int start, size_t len);
void *ft_memset(void *b, int c, size_t len);
void *ft_memcpy(void *dst, const void *src, size_t n);
void *ft_memccpy(void *dst, const void *src,
diff --git a/libft/src/ft_substr_s.c b/libft/src/ft_substr_s.c
new file mode 100644
index 0000000..2bf4dd4
--- /dev/null
+++ b/libft/src/ft_substr_s.c
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_substr_s.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:07:15 by rbousset #+# #+# */
+/* Updated: 2020/02/14 17:07:15 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+
+void ft_substr_s(char str[], const char *s, unsigned int start, size_t len)
+{
+ ft_strlcpy(str, s + start, len + 1);
+}