From 214eae8a55bde34ca412084bebdb378a696152cc Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 1 Dec 2020 16:12:02 +0100 Subject: Bav --- libft/Makefile | 1 + libft/include/libft.h | 2 ++ libft/src/ft_substr_s.c | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 libft/src/ft_substr_s.c (limited to 'libft') 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 +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:07:15 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:07:15 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_substr_s(char str[], const char *s, unsigned int start, size_t len) +{ + ft_strlcpy(str, s + start, len + 1); +} -- cgit v1.2.3