diff --git a/Makefile b/Makefile index 079c626..e725a23 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ SRCS = ft_memset.c \ ft_tolower.c \ ft_strchr.c \ ft_strrchr.c \ + ft_strchrset.c \ ft_strncmp.c \ ft_strlcpy.c \ ft_strlcat.c \ diff --git a/libft.h b/libft.h index de5dcca..931dc8a 100644 --- a/libft.h +++ b/libft.h @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/11/25 14:45:53 by hulamy #+# #+# */ -/* Updated: 2019/11/26 18:46:22 by hulamy ### ########.fr */ +/* Updated: 2020/02/16 15:10:37 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,6 +33,7 @@ int ft_toupper(int c); int ft_tolower(int c); char *ft_strchr(const char *s, int c); char *ft_strrchr(const char *s, int c); +int ft_strchrset(char *s, char *set); int ft_strncmp(const char *s1, const char *s2, size_t n); size_t ft_strlcpy(char *dst, const char *src, size_t size); size_t ft_strlcat(char *dst, const char *src, size_t size); diff --git a/srcs/ft_strchrset.c b/srcs/ft_strchrset.c new file mode 100644 index 0000000..624e87f --- /dev/null +++ b/srcs/ft_strchrset.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strchrset.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/16 15:07:11 by hulamy #+# #+# */ +/* Updated: 2020/02/16 15:12:03 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* +** return 1 if any character of the character set is found in s +** else return 0 +*/ + +#include "libft.h" + +int ft_strchrset(char *s, char *set) +{ + int i; + + i = 0; + while (set[i] != '\0') + { + if (ft_strchr(s, set[i]) != NULL) + return (1); + i++; + } + return (0); +}