aboutsummaryrefslogtreecommitdiff
path: root/src/str/ft_strcspn.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-02-10 04:33:35 +0100
committerCharles <sircharlesaze@gmail.com>2020-02-10 04:33:35 +0100
commit8e3c9342ce7e4932c4a59c0823af63d19ade8046 (patch)
tree79ec970d0e794fc4d1bde5c0c87909627dd455c7 /src/str/ft_strcspn.c
parentfc457992114e71989e5cdeab452bc054a400a397 (diff)
downloadlibft-8e3c9342ce7e4932c4a59c0823af63d19ade8046.tar.gz
libft-8e3c9342ce7e4932c4a59c0823af63d19ade8046.tar.bz2
libft-8e3c9342ce7e4932c4a59c0823af63d19ade8046.zip
Added ft_strspn, ft_strcspn
Diffstat (limited to 'src/str/ft_strcspn.c')
-rw-r--r--src/str/ft_strcspn.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/str/ft_strcspn.c b/src/str/ft_strcspn.c
new file mode 100644
index 0000000..7cc06a5
--- /dev/null
+++ b/src/str/ft_strcspn.c
@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_strcspn.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/10 04:30:59 by cacharle #+# #+# */
+/* Updated: 2020/02/10 04:32:15 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft_str.h"
+
+size_t ft_strcspn(const char *s, const char *charset)
+{
+ int i;
+
+ i = 0;
+ while (ft_strchr(charset, s[i]) == NULL)
+ i++;
+ return (i);
+}