From d1ee0c0e55f75432da026f5e0e7cf15cee6918da Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 4 Aug 2020 14:28:35 +0200 Subject: New libft function strclen, bug fix --- libft/src/ft_strclen.c | 24 ++++++++++++++++++++++++ libft/src/ft_strlen.c | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 libft/src/ft_strclen.c (limited to 'libft/src') diff --git a/libft/src/ft_strclen.c b/libft/src/ft_strclen.c new file mode 100644 index 0000000..fe88ca5 --- /dev/null +++ b/libft/src/ft_strclen.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strclen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:07:12 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:07:12 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include + +size_t + ft_strclen(const char *s, int c) +{ + const char *ptr; + + ptr = s; + while (ptr != NULL && *ptr != '\0' && *ptr != c) + ptr++; + return (ptr - s); +} diff --git a/libft/src/ft_strlen.c b/libft/src/ft_strlen.c index 90f5110..2b26bf0 100644 --- a/libft/src/ft_strlen.c +++ b/libft/src/ft_strlen.c @@ -18,7 +18,7 @@ size_t const char *ptr; ptr = s; - while (ptr && *ptr) + while (ptr != NULL && *ptr != '\0') ptr++; return (ptr - s); } -- cgit v1.2.3